Part Number Hot Search : 
LLZ2V009 2SC4907 28010 736MH KDR377 BT204 ST3237EB 60GU3
Product Description
Full Text Search
 

To Download 16F914 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2007 microchip technology inc. ds41250f pic16f913/914/916/917/946 data sheet 28/40/44/64-pin flash-based, 8-bit cmos microcontrollers with lcd driver and nanowatt technology
ds41250f-page ii ? 2007 microchip technology inc. information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. microchip makes no representations or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose . microchip disclaims all liability arising from this information and its use. use of microchip devices in life support and/or safety applications is entirely at the buyer?s risk, and the buyer agrees to defend, indemnify and hold harmless microchip from any and all damages, claims, suits, or expenses resulting from such use. no licenses are conveyed, implicitly or otherwise, under any microchip intellectual property rights. trademarks the microchip name and logo, the microchip logo, accuron, dspic, k ee l oq , k ee l oq logo, micro id , mplab, pic, picmicro, picstart, pro mate, powersmart, rfpic, and smartshunt are registered trademarks of microchip technology incorporated in the u.s.a. and other countries. amplab, filterlab, linear active thermistor, migratable memory, mxdev, mxlab, ps logo, seeval, smartsensor and the embedded control solutions company are registered trademarks of micr ochip technology incorporated in the u.s.a. analog-for-the-digital age, appl ication maestro, codeguard, dspicdem, dspicdem.net, dspicworks, ecan, economonitor, fansense, flexrom, fuzzylab, in-circuit serial programming, icsp, icepic, mindi, miwi, mpasm, mplab certified logo, mplib, mplink, pickit, picdem, picdem.net, piclab, pictail, powercal, powerinfo, powermate, powe rtool, real ice, rflab, rfpicdem, select mode, smart serial, smarttel, total endurance, uni/o, wiperlock and zena are trademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of microchip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2007, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. note the following details of the code protection feature on microchip devices: ? microchip products meet the specification cont ained in their particular microchip data sheet. ? microchip believes that its family of products is one of the mo st secure families of its kind on the market today, when used i n the intended manner and under normal conditions. ? there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip produc ts in a manner outside the operating specifications contained in microchip?s data sheets. most likely, the person doing so is engaged in theft of intellectual property. ? microchip is willing to work with the customer who is concerned about the integrity of their code. ? neither microchip nor any other semiconductor manufacturer c an guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ?unbreakable.? code protection is constantly evolving. we at microchip are co mmitted to continuously improvi ng the code protection features of our products. attempts to break microchip?s c ode protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona; gresham, oregon and design centers in california and india. the company?s quality system processes and procedures are for its pic ? mcus and dspic ? dscs, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory and analog products. in addition, microchip?s quality system for the design and manufacture of development systems is iso 9001:2000 certified.
? 2007 microchip technology inc. ds41250f-page 1 pic16f913/914/916/917/946 high-performance risc cpu: ? only 35 instructions to learn: - all single-cycle instructions except branches ? operating speed: - dc ? 20 mhz oscillator/clock input - dc ? 200 ns instruction cycle ? program memory read (pmr) capability ? interrupt capability ? 8-level deep hardware stack ? direct, indirect and relative addressing modes special microcontroller features: ? precision internal oscillator: - factory calibrated to 1%, typical - software selectable frequency range of 8 mhz to 125 khz - software tunable - two-speed start-up mode - external oscillator fail detect for critical applications - clock mode switching during operation for power savings ? software selectable 31 khz internal oscillator ? power-saving sleep mode ? wide operating voltage range (2.0v-5.5v) ? industrial and extended temperature range ? power-on reset (por) ? power-up timer (pwrt) and oscillator start-up timer (ost) ? brown-out reset (bor) with software control option ? enhanced low-current watchdog timer (wdt) with on-chip oscillator (software selectable nominal 268 seconds with full prescaler) with software enable ? multiplexed master clear with pull-up/input pin ? programmable code protection ? high-endurance flash/eeprom cell: - 100,000 write flash endurance - 1,000,000 write eeprom endurance - flash/data eeprom retention: > 40 years low-power features: ? standby current: - <100 na @ 2.0v, typical ? operating current: -11 a @ 32 khz, 2.0v, typical -220 a @ 4 mhz, 2.0v, typical ? watchdog timer current: -1 a @ 2.0v, typical peripheral features: ? liquid crystal display module: - up to 60/96/168 pixel drive capability on 28/40/64-pin devices, respectively - four commons ? up to 24/35/53 i/o pins and 1 input-only pin: - high-current source/sink for direct led drive - interrupt-on-change pin - individually programmable weak pull-ups ? in-circuit serial programming? (icsp?) via two pins ? analog comparator module with: - two analog comparators - programmable on-chip voltage reference (cv ref ) module (% of v dd ) - comparator inputs and outputs externally accessible ? a/d converter: - 10-bit resolution and up to 8 channels ? timer0: 8-bit timer/counter with 8-bit programmable prescaler ? enhanced timer1: - 16-bit timer/counter with prescaler - external timer1 gate (count enable) - option to use osc1 and osc2 as timer1 oscillator if intoscio or lp mode is selected ? timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler ? addressable universal synchronous asynchronous receiver transmitter (ausart) ? up to 2 capture, compare, pwm modules: - 16-bit capture, max. resolution 12.5 ns - 16-bit compare, max. resolution 200 ns - 10-bit pwm, max. frequency 20 khz ? synchronous serial port (ssp) with i 2 c ? 28/40/44/64-pin flash-based, 8-bit cmos microcontrollers with lcd driver and nanowatt technology
pic16f913/914/916/917/946 ds41250f-page 2 ? 2007 microchip technology inc. pin diagrams ? pic16F914/917, 40-pin device program memory data memory i/o 10-bit a/d (ch) lcd (segment drivers) ccp timers 8/16-bit flash (words/bytes) sram (bytes) eeprom (bytes) pic16f913 4k/7k 256 256 24 5 16 (1) 12/1 pic16F914 4k/7k 256 256 35 8 24 2 2/1 pic16f916 8k/14k 352 256 24 5 16 (1) 12/1 pic16f917 8k/14k 352 256 35 8 24 2 2/1 pic16f946 8k/14k 336 256 53 8 42 2 2/1 note 1: com3 and seg15 share the same physical pin on the pic16f913/916, therefore seg15 is not available when using 1/4 multiplex displays. 40-pin pdip 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 pic16F914/917 re3/mclr /v pp ra0/an0/c1-/seg12 ra1/an1/c2-/seg7 ra2/an2/c2+/v ref -/com2 ra3/an3/c1+/v ref +/seg15 ra4/c1out/t0cki/seg4 ra5/an4/c2out/ss /seg5 re0/an5/seg21 re1/an6/seg22 re2/an7/seg23 v dd v ss ra7/osc1/clkin/t1osi ra6/osc2/clkout/t1oso rc0/vlcd1 rc1/vlcd2 rc2/vlcd3 rc3/seg6 rd0/com3 rd1 rb7/icspdat/icddat/seg13 rb6/icspclk/icdck/seg14 rb5/com1 rb4/com0 rb3/seg3 rb2/seg2 rb1/seg1 rb0/int/seg0 v dd v ss rd7/seg20 rd6/seg19 rd5/seg18 rd4/seg17 rc7/rx/dt/sdi/sda/seg8 rc6/tx/ck/sck/scl/seg9 rc5/t1cki/ccp1/seg10 rc4/t1g /sdo/seg11 rd3/seg16 rd2/ccp2
? 2007 microchip technology inc. ds41250f-page 3 pic16f913/914/916/917/946 table 1: pic16F914/917 40-pin summary i/o pin a/d lcd comparators timers ccp ausart ssp interrupt pull-up basic ra0 2 an0 seg12 c1- ? ? ? ? ? ? ? ra1 3 an1 seg7 c2- ? ? ? ? ? ? ? ra2 4 an2/v ref - com2 c2+ ? ? ? ? ? ? ? ra3 5 an3/v ref + seg15 c1+ ? ? ? ? ? ? ? ra4 6 seg4 c1out t0cki ? ? ? ? ? ? ra5 7 an4 seg5 c2out ? ? ? ss ?? ? ra6 14 ? ? ? t1oso ? ? ? ? ? osc2/clkout ra7 13 ? ? ? t1osi ? ? ? ? ? osc1/clkin rb0 33 ? seg0 ? ? ? ? ? int y ? rb1 34 ? seg1 ? ? ? ? ? ? y ? rb2 35 ? seg2 ? ? ? ? ? ? y ? rb3 36 ? seg3 ? ? ? ? ? ? y ? rb4 37 ? com0 ? ? ? ? ? ioc y ? rb5 38 ? com1 ? ? ? ? ? ioc y ? rb6 39 ? seg14 ? ? ? ? ? ioc y icspclk/icdck rb7 40 ? seg13 ? ? ? ? ? ioc y icspdat/icddat rc0 15 ? vlcd1 ? ? ? ? ? ? ? ? rc1 16 ? vlcd2 ? ? ? ? ? ? ? ? rc2 17 ? vlcd3 ? ? ? ? ? ? ? ? rc3 18 ? seg6 ? ? ? ? ? ? ? ? rc4 23 ? seg11 ? t1g ? ? sdo ? ? ? rc5 24 ? seg10 ? t1cki ccp1 ? ? ? ? ? rc6 25 ? seg9 ? ? ? tx/ck sck/scl ? ? ? rc7 26 ? seg8 ? ? ? rx/dt sdi/sda ? ? ? rd0 19 ? com3 ? ? ? ? ? ? ? ? rd1 20 ? ? ? ? ? ? ? ? ? ? rd2 21 ? ? ? ? ccp2 ? ? ? ? ? rd3 22 ? seg16 ? ? ? ? ? ? ? ? rd4 27 ? seg17 ? ? ? ? ? ? ? ? rd5 28 ? seg18 ? ? ? ? ? ? ? ? rd6 29 ? seg19 ? ? ? ? ? ? ? ? rd7 30 ? seg20 ? ? ? ? ? ? ? ? re0 8 an5 seg21 ? ? ? ? ? ? ? ? re1 9 an6 seg22 ? ? ? ? ? ? ? ? re2 10 an7 seg23 ? ? ? ? ? ? ? ? re3 1 ? ? ? ? ? ? ? ? y (1) mclr /v pp ? 11 ? ? ? ? ? ? ? ? ? v dd ?32 ? ? ? ? ? ? ? ? ? v dd ? 12 ? ? ? ? ? ? ? ? ? v ss ?31 ? ? ? ? ? ? ? ? ? v ss note 1: pull-up enabled only with external mclr configuration.
pic16f913/914/916/917/946 ds41250f-page 4 ? 2007 microchip technology inc. pin diagrams ? pic16f913/916, 28-pin 28-pin pdip, soic, ssop 28-pin qfn 10 11 2 3 4 5 6 1 8 7 9 12 13 14 15 16 17 18 19 20 23 24 25 26 27 28 22 21 pic16f913/916 re3/mclr /v pp ra0/an0/c1-/seg12 ra1/an1/c2-/seg7 ra2/an2/c2+/v ref -/com2 ra3/an3/c1+/v ref +/com3/seg15 ra4/c1out/t0cki/seg4 ra5/an4/c2out/ss /seg5 v ss ra7/osc1/clkin/t1osi ra6/osc2/clkout/t1oso rc0/vlcd1 rc1/vlcd2 rc2/vlcd3 rc3/seg6 rb7/icspdat/icddat/seg13 rb6/icspclk/icdck/seg14 rb5/com1 rb4/com0 rb3/seg3 rb2/seg2 rb1/seg1 rb0/int/seg0 v dd v ss rc7/rx/dt/sdi/sda/seg8 rc6/tx/ck/sck/scl/seg9 rc5/t1cki/ccp1/seg10 rc4/t1g /sdo/seg11 16 2 7 1 3 6 5 4 15 21 19 20 17 18 22 28 26 27 23 24 25 14 8 10 9 13 12 11 pic16f913/916 ra1/an1/c2-/seg7 ra0/an0/c1-/seg12 re3/mclr /v pp rb7/icspdat/icddat/seg13 rb6/icspclk/icdck/seg14 rb5/com1 rb4/com0 rc0/vlcd1 rc1/vlcd2 rc2/vlcd3 rc3/seg6 rc4/t1g /sdo/seg11 rc5/t1cki/ccp1/seg10 rc6/tx/ck/sck/scl/seg9 ra2/an2/c2+/v ref -/com2 ra3/an3/c1+/v ref +/com3/seg15 ra4/c1out/t0cki/seg4 ra5/an4/c2out/ss /seg5 v ss ra7/osc1/clkin/t1osi ra6/osc2/clkout/t1oso rb3/seg3 rb2/seg2 rb1/seg1 rb0/int/seg0 v dd v ss rc7/rx/dt/sdi/sda/seg8
? 2007 microchip technology inc. ds41250f-page 5 pic16f913/914/916/917/946 table 2: pic16f913/916 28-pin (pdip, soic, ssop) summary i/o pin a/d lcd comparators timers ccp ausart ssp interrupt pull-up basic ra0 2 an0 seg12 c1- ? ? ? ? ? ? ? ra1 3 an1 seg7 c2- ? ? ? ? ? ? ? ra2 4 an2/v ref - com2 c2+ ? ? ? ? ? ? ? ra3 5 an3/v ref + seg15/ com3 c1+ ? ? ? ? ? ? ? ra4 6 ? seg4 c1out t0cki ? ? ? ? ? ? ra5 7 ? seg5 c2out ? ? ? ss ?? ? ra6 10 ? ? ? t1oso ? ? ? ? ? osc2/clkout ra7 9 ? ? ? t1osi ? ? ? ? ? osc1/clkin rb0 21 ? seg0 ? ? ? ? ? int y ? rb1 22 ? seg1 ? ? ? ? ? ? y ? rb2 23 ? seg2 ? ? ? ? ? ? y ? rb3 24 ? seg3 ? ? ? ? ? ? y ? rb4 25 ? com0 ? ? ? ? ? ioc y ? rb5 26 ? com1 ? ? ? ? ? ioc y ? rb6 27 ? seg14 ? ? ? ? ? ioc y icspclk/icdck rb7 28 ? seg13 ? ? ? ? ? ioc y icspdat/icddat rc0 11 ? vlcd1 ? ? ? ? ? ? ? ? rc1 12 ? vlcd2 ? ? ? ? ? ? ? ? rc2 13 ? vlcd3 ? ? ? ? ? ? ? ? rc3 14 ? seg6 ? ? ? ? ? ? ? ? rc4 15 ? seg11 ? t1g ? ? sdo ? ? ? rc5 16 ? seg10 ? t1cki ccp1 ? ? ? ? ? rc6 17 ? seg9 ? ? ? tx/ck sck/scl ? ? ? rc7 18 ? seg8 ? ? ? rx/dt sdi/sda ? ? ? re3 1 ? ? ? ? ? ? ? ? y (1) mclr /v pp ?20????????? v dd ? 8 ? ? ? ? ? ? ? ? ? v ss ?19????????? v ss note 1: pull-up enabled only with external mclr configuration.
pic16f913/914/916/917/946 ds41250f-page 6 ? 2007 microchip technology inc. table 3: pic16f913/916 28-pin (qfn) summary i/o pin a/d lcd comparators timers ccp ausart ssp interrupt pull-up basic ra0 27 an0 seg12 c1- ? ? ? ? ? ? ? ra1 28 an1 seg7 c2- ? ? ? ? ? ? ? ra2 1 an2/v ref - com2 c2+ ? ? ? ? ? ? ? ra3 2 an3/v ref + seg15/ com3 c1+ ? ? ? ? ? ? ? ra4 3 ? seg4 c1out t0cki ? ? ? ? ? ? ra5 4 an4 seg5 c2out ? ? ? ss ?? ? ra6 7 ? ? ? t1oso ? ? ? ? ? osc2/clkout ra7 6 ? ? ? t1osi ? ? ? ? ? osc1/clkin rb0 18 ? seg0 ? ? ? ? ? int y ? rb1 19 ? seg1 ? ? ? ? ? ? y ? rb2 20 ? seg2 ? ? ? ? ? ? y ? rb3 21 ? seg3 ? ? ? ? ? ? y ? rb4 22 ? com0 ? ? ? ? ? ioc y ? rb5 23 ? com1 ? ? ? ? ? ioc y ? rb6 24 ? seg14 ? ? ? ? ? ioc y icspclk/icdck rb7 25 ? seg13 ? ? ? ? ? ioc y icspdat/icddat rc0 8 ? vlcd1 ? ? ? ? ? ? ? ? rc1 9 ? vlcd2 ? ? ? ? ? ? ? ? rc2 10 ? vlcd3 ? ? ? ? ? ? ? ? rc3 11 ? seg6 ? ? ? ? ? ? ? ? rc4 12 ? seg11 ? t1g ? ? sdo ? ? ? rc5 13 ? seg10 ? t1cki ccp1 ? ? ? ? ? rc6 14 ? seg9 ? ? ? tx/ck sck/scl ? ? ? rc7 15 ? seg8 ? ? ? rx/dt sdi/sda ? ? ? re3 26 ? ? ? ? ? ? ? ? y (1) mclr /v pp ?17????????? v dd ? 5 ? ? ? ? ? ? ? ? ? v ss ?16????????? v ss note 1: pull-up enabled only with external mclr configuration.
? 2007 microchip technology inc. ds41250f-page 7 pic16f913/914/916/917/946 pin diagrams ? pic16F914/917, 44-pin 44-pin tqfp 10 11 2 3 6 1 18 19 20 21 22 12 13 14 15 38 8 7 44 43 42 41 40 39 16 17 29 30 31 32 33 23 24 25 26 27 28 36 34 35 9 37 5 4 pic16F914/917 nc rc0/vlcd1 ra6/osc2/clkout/t1oso ra7/osc1/clkin/t1osi v ss v dd re2/an7/seg23 re1/an6/seg22 re0/an5/seg21 ra5/an4/c2out/ss /seg5 ra4/c1out/t0cki/seg4 rc7/rx/dt/sdi/sda/seg8 rd4/seg17 rd5/seg18 rd6/seg19 rd7/seg20 v ss v dd rb0/seg0/int rb1/seg1 rb2/seg2 rb3/seg3 nc nc rb4/com0 rb5/com1 rb6/icspclk/icdck/seg14 rb7/icspdat/icddat/seg13 re3/mclr /v pp ra0/c1-/an0/seg12 ra1/c2-/an1/seg7 ra2/an2/c2+/v ref -/com2 ra3/an3/v ref +/c1+/seg15 rc6/tx/ck/sck/scl/seg9 rc5/t1cki/ccp1/seg10 rc4/t1g /sdo/seg11 rd3/seg16 rd2/ccp2 rd1 rd0/com3 rc3/seg6 rc2/vlcd3 rc1/vlcd2 nc 44-pin qfn 10 11 2 3 6 1 18 19 20 21 22 12 13 14 15 38 8 7 44 43 42 41 40 39 16 17 29 30 31 32 33 23 24 25 26 27 28 36 34 35 9 37 5 4 pic16F914/917 ra6/osc2/clkout/t1oso ra7/osc1/clkin/t1osi v ss v ss nc v dd re2/an7/seg23 re1/an6/seg22 re0/an5/seg21 ra5/an4/c2out/ss /seg5 ra4/c1out/t0cki/seg4 rc7/rx/dt/sdi/sda/seg8 rd4/seg17 rd5/seg18 rd6/seg19 rd7/seg20 v ss v dd v dd rb0/int/seg0 rb1/seg1 rb2/seg2 rb3/seg3 nc rb4/com0 rb5/com1 rb6/icspclk/icdck/seg14 rb7/icspdat/icddat/seg13 re3/mclr /v pp ra0/an0/c1-/seg12 ra1/an1/c2-/seg7 ra2/an2/c2+/v ref -/com2 ra3/an3/c1+/v ref +/seg15 rc6/tx/ck/sck/scl/seg9 rc5/t1cki/ccp1/seg10 rc4/t1g /sdo/seg11 rd3/seg16 rd2/ccp2 rd1 rd0/com3 rc3/seg6 rc2/vlcd3 rc1/vlcd2 rc0/vldc1
pic16f913/914/916/917/946 ds41250f-page 8 ? 2007 microchip technology inc. table 4: pic16F914/917 44-pin (tqfp) summary i/o pin a/d lcd comparators timers ccp ausart ssp interrupt pull-up basic ra0 19 an0 seg12 c1- ? ? ? ? ? ? ? ra1 20 an1 seg7 c2- ? ? ? ? ? ? ? ra2 21 an2/v ref - com2 c2+ ? ? ? ? ? ? ? ra3 22 an3/v ref + seg15 c1+ ? ? ? ? ? ? ? ra4 23 ? seg4 c1out t0cki ? ? ? ? ? ? ra5 24 an4 seg5 c2out ? ? ? ss ?? ? ra6 31 ? ? ? t1oso ? ? ? ? ? osc2/clkout ra7 30 ? ? ? t1osi ? ? ? ? ? osc1/clkin rb0 8 ? seg0 ? ? ? ? ? int y ? rb1 9 ? seg1 ? ? ? ? ? ? y ? rb2 10 ? seg2 ? ? ? ? ? ? y ? rb3 11 ? seg3 ? ? ? ? ? ? y ? rb4 14 ? com0 ? ? ? ? ? ioc y ? rb5 15 ? com1 ? ? ? ? ? ioc y ? rb6 16 ? seg14 ? ? ? ? ? ioc y icspclk/icdck rb7 17 ? seg13 ? ? ? ? ? ioc y icspdat/icddat rc0 32 ? vlcd1 ? ? ? ? ? ? ? ? rc1 35 ? vlcd2 ? ? ? ? ? ? ? ? rc2 36 ? vlcd3 ? ? ? ? ? ? ? ? rc3 37 ? seg6 ? ? ? ? ? ? ? ? rc4 42 ? seg11 ? t1g ? ? sdo ? ? ? rc5 43 ? seg10 ? t1cki ccp1 ? ? ? ? ? rc6 44 ? seg9 ? ? ? tx/ck sck/scl ? ? ? rc7 1 ? seg8 ? ? ? rx/dt sdi/sda ? ? ? rd0 38 ? com3 ? ? ? ? ? ? ? ? rd1 39 ? ? ? ? ? ? ? ? ? ? rd2 40 ? ? ? ? ccp2 ? ? ? ? ? rd3 41 ? seg16 ? ? ? ? ? ? ? ? rd4 2 ? seg17 ? ? ? ? ? ? ? ? rd5 3 ? seg18 ? ? ? ? ? ? ? ? rd6 4 ? seg19 ? ? ? ? ? ? ? ? rd7 5 ? seg20 ? ? ? ? ? ? ? ? re0 25 an5 seg21 ? ? ? ? ? ? ? ? re1 26 an6 seg22 ? ? ? ? ? ? ? ? re2 27 an7 seg23 ? ? ? ? ? ? ? ? re318????????y (1) mclr /v pp ? 7 ? ? ? ? ? ? ? ? ? v dd ?28????????? v dd ? 6 ? ? ? ? ? ? ? ? ? v ss ?29????????? v ss ? 12 ? ? ? ? ? ? ? ? ? nc ?13????????? nc ? 33 ? ? ? ? ? ? ? ? ? nc ?34????????? nc note 1: pull-up enabled only with external mclr configuration.
? 2007 microchip technology inc. ds41250f-page 9 pic16f913/914/916/917/946 table 5: pic16F914/917 44-pin (qfn) summary i/o pin a/d lcd comparators timers ccp ausart ssp interrupt pull-up basic ra0 19 an0 seg12 c1- ? ? ? ? ? ? ? ra1 20 an1 seg7 c2- ? ? ? ? ? ? ? ra2 21 an2/v ref - com2 c2+ ? ? ? ? ? ? ? ra3 22 an3/v ref + seg15 c1+ ? ? ? ? ? ? ? ra4 23 ? seg4 c1out t0cki ? ? ? ? ? ? ra5 24 an4 seg5 c2out ? ? ? ss ?? ? ra6 33 ? ? ? t1oso ? ? ? ? ? osc2/clkout ra7 32 ? ? ? t1osi ? ? ? ? ? osc1/clkin rb0 9 ? seg0 ? ? ? ? ? int y ? rb1 10 ? seg1 ? ? ? ? ? ? y ? rb2 11 ? seg2 ? ? ? ? ? ? y ? rb3 12 ? seg3 ? ? ? ? ? ? y ? rb4 14 ? com0 ? ? ? ? ? ioc y ? rb5 15 ? com1 ? ? ? ? ? ioc y ? rb6 16 ? seg14 ? ? ? ? ? ioc y icspclk/icdck rb7 17 ? seg13 ? ? ? ? ? ioc y icspdat/icddat rc0 34 ? vlcd1 ? ? ? ? ? ? ? ? rc1 35 ? vlcd2 ? ? ? ? ? ? ? ? rc2 36 ? vlcd3 ? ? ? ? ? ? ? ? rc3 37 ? seg6 ? ? ? ? ? ? ? ? rc4 42 ? seg11 ? t1g ? ? sdo ? ? ? rc5 43 ? seg10 ? t1cki ccp1 ? ? ? ? ? rc6 44 ? seg9 ? ? ? tx/ck sck/scl ? ? ? rc7 1 ? seg8 ? ? ? rx/dt sdi/sda ? ? ? rd0 38 ? com3 ? ? ? ? ? ? ? ? rd1 39 ? ? ? ? ? ? ? ? ? ? rd2 40 ? ? ? ? ccp2 ? ? ? ? ? rd3 41 ? seg16 ? ? ? ? ? ? ? ? rd4 2 ? seg17 ? ? ? ? ? ? ? ? rd5 3 ? seg18 ? ? ? ? ? ? ? ? rd6 4 ? seg19 ? ? ? ? ? ? ? ? rd7 5 ? seg20 ? ? ? ? ? ? ? ? re0 25 an5 seg21 ? ? ? ? ? ? ? ? re1 26 an6 seg22 ? ? ? ? ? ? ? ? re2 27 an7 seg23 ? ? ? ? ? ? ? ? re318????????y (1) mclr /v pp ? 7 ? ? ? ? ? ? ? ? ? v dd ?8????????? v dd ? 28 ? ? ? ? ? ? ? ? ? v dd ?6????????? v ss ? 30 ? ? ? ? ? ? ? ? ? v ss ?13????????? nc ? 29 ? ? ? ? ? ? ? ? ? nc note 1: pull-up enabled only with external mclr configuration.
pic16f913/914/916/917/946 ds41250f-page 10 ? 2007 microchip technology inc. pin diagram ? pic16f946 1 2 3 4 5 6 7 8 9 10 11 12 13 14 38 37 36 35 34 33 50 49 17 18 19 20 21 22 23 24 25 26 rd6/seg19 rd5/seg18 rd4/seg17 rc7/rx/dt/sdi/sda/seg8 rc6/tx/ck/sck/scl/seg9 rc5/t1cki/ccp1/seg10 rc4/t1g /sdo/seg11 v dd v ss rd3/seg16 rd2/ccp2 rd1 rd0/com3 rc3/seg6 rc2/vlcd3 rc1/vlcd2 rd7/seg20 rg5/seg41 rg4/seg40 rg3/seg39 rg2/seg38 rg1/seg37 rg0/seg36 v ss v dd rf1/seg33 rf0/seg32 rb0/int/seg0 rb1/seg1 rb2/seg2 rc0/vlcd1 ra6/osc2/clkout/t1oso ra7/osc1/clkin/t1osi v ss v dd re2/an7/seg23 re1/an6/seg22 re0/an5/seg21 ra4/c1out/t0cki/seg4 ra3/an3/c1+/v ref +/seg15 ra5/an4/c2out/ss /seg5 ra2/an2/c2+/v ref -/com2 ra0/an0/c1-/seg12 re3/mclr /v pp re4/seg24 rb4/com0 rb3/seg3 av dd av ss rb5/com1 rb6/icspclk/icdck/seg14 rb7/icspdat/icddat/seg13 rf7/seg31 v ss v dd rf5/seg29 rf6/seg30 rf4/seg28 re7/seg27 re5/seg25 re6/seg26 ra1/an1/c2-/seg7 15 16 31 40 39 27 28 29 30 32 48 47 46 45 44 43 42 41 54 53 52 51 58 57 56 55 60 59 64 63 62 61 64-pin tqfp rf2/seg34 rf3/seg35 pic16f946
? 2007 microchip technology inc. ds41250f-page 11 pic16f913/914/916/917/946 table 6: pic16f946 64-pin (tqfp) summary i/o pin a/d lcd comparators timers ccp ausart ssp interrupt pull-up basic ra0 27 an0 seg12 c1- ? ? ? ? ? ? ? ra1 28 an1 seg7 c2- ? ? ? ? ? ? ? ra2 29 an2/v ref - com2 c2+ ? ? ? ? ? ? ? ra3 30 an3/v ref + seg15 c1+ ? ? ? ? ? ? ? ra4 31 ? seg4 c1out t0cki ? ? ? ? ? ? ra5 32 an4 ? c2out ? ? ? ss ?? ? ra6 40 seg5 ? ? t1oso ? ? ? ? ? osc2/clkout ra7 39 ? ? ? t1osi ? ? ? ? ? osc1/clkin rb0 15 ? seg0 ? ? ? ? ? int y ? rb1 16 ? seg1 ? ? ? ? ? ? y ? rb2 17 ? seg2 ? ? ? ? ? ? y ? rb3 18 ? seg3 ? ? ? ? ? ? y ? rb4 21 ? com0 ? ? ? ? ? ioc y ? rb5 22 ? com1 ? ? ? ? ? ioc y ? rb6 23 ? seg14 ? ? ? ? ? ioc y icspclk/icdck rb7 24 ? seg13 ? ? ? ? ? ioc y icspdat/icddat rc0 49 ? vlcd1 ? ? ? ? ? ? ? ? rc1 50 ? vlcd2 ? ? ? ? ? ? ? ? rc2 51 ? vlcd3 ? ? ? ? ? ? ? ? rc3 52 ? seg6 ? ? ? ? ? ? ? ? rc4 59 ? seg11 ? t1g ? ? sdo ? ? ? rc5 60 ? seg10 ? t1cki ccp1 ? ? ? ? ? rc6 61 ? seg9 ? ? ? tx/ck sck/scl ? ? ? rc7 62 ? seg8 ? ? ? rx/dt sdi/sda ? ? ? rd0 53 ? com3 ? ? ? ? ? ? ? ? rd1 54 ? ? ? ? ? ? ? ? ? ? rd2 55 ? ? ? ? ccp2 ? ? ? ? ? rd3 58 ? seg16 ? ? ? ? ? ? ? ? rd4 63 ? seg17 ? ? ? ? ? ? ? ? rd5 64 ? seg18 ? ? ? ? ? ? ? ? rd6 1 ? seg19 ? ? ? ? ? ? ? ? rd7 2 ? seg20 ? ? ? ? ? ? ? ? re0 33 an5 seg21 ? ? ? ? ? ? ? ? re1 34 an6 seg22 ? ? ? ? ? ? ? ? re2 35 an7 seg23 ? ? ? ? ? ? ? ? re3 36 ? ? ? ? ? ? ? ? y (1) mclr /v pp re4 37 ? seg24 ? ? ? ? ? ? ? ? re5 42 ? seg25 ? ? ? ? ? ? ? ? re6 43 ? seg26 ? ? ? ? ? ? ? ? re7 44 ? seg27 ? ? ? ? ? ? ? ? rf0 11 ? seg32 ? ? ? ? ? ? ? ? rf1 12 ? seg33 ? ? ? ? ? ? ? ? rf2 13 ? seg34 ? ? ? ? ? ? ? ? note 1: pull-up enabled only with external mclr configuration.
pic16f913/914/916/917/946 ds41250f-page 12 ? 2007 microchip technology inc. rf3 14 ? seg35 ? ? ? ? ? ? ? ? rf4 45 ? seg28 ? ? ? ? ? ? ? ? rf5 46 ? seg29 ? ? ? ? ? ? ? ? rf6 47 ? seg30 ? ? ? ? ? ? ? ? rf7 48 ? seg31 ? ? ? ? ? ? ? ? rg0 3 ? seg36 ? ? ? ? ? ? ? ? rg1 4 ? seg37 ? ? ? ? ? ? ? ? rg2 5 ? seg38 ? ? ? ? ? ? ? ? rg3 6 ? seg39 ? ? ? ? ? ? ? ? rg4 7 ? seg40 ? ? ? ? ? ? ? ? rg5 8 ? seg41 ? ? ? ? ? ? ? ? ? 26 ? ? ? ? ? ? ? ? ? av dd ?25 ? ? ? ? ? ? ? ? ? av ss ? 10 ? ? ? ? ? ? ? ? ? v dd ?19 ? ? ? ? ? ? ? ? ? v dd ? 38 ? ? ? ? ? ? ? ? ? v dd ?57 ? ? ? ? ? ? ? ? ? v dd ? 9 ? ? ? ? ? ? ? ? ? v ss ?20 ? ? ? ? ? ? ? ? ? v ss ? 41 ? ? ? ? ? ? ? ? ? v ss ?56 ? ? ? ? ? ? ? ? ? v ss table 6: pic16f946 64-pin (tqfp) summary (continued) i/o pin a/d lcd comparators timers ccp ausart ssp interrupt pull-up basic note 1: pull-up enabled only with external mclr configuration.
? 2007 microchip technology inc. ds41250f-page 13 pic16f913/914/916/917/946 table of contents 1.0 device overview ............................................................................................................. ........................................................... 15 2.0 memory organization ......................................................................................................... ........................................................ 23 3.0 i/o ports ................................................................................................................... .................................................................. 43 4.0 oscillator module (with fail-safe clock monitor)............................................................................ ........................................... 87 5.0 timer0 module ............................................................................................................... ............................................................ 99 6.0 timer1 module with gate control............................................................................................. ................................................ 102 7.0 timer2 module ............................................................................................................... .......................................................... 107 8.0 comparator module........................................................................................................... ....................................................... 109 9.0 addressable universal synchronous asynchr onous receiver transmitter (ausart) ................................................ ........... 121 10.0 liquid crystal display (lcd) driver module................................................................................. ............................................ 143 11.0 programmable low-voltage detect (plvd) module.............................................................................. .................................. 171 12.0 analog-to-digital converter (adc) module ................................................................................... ........................................... 175 13.0 data eeprom and flash program memory control ............................................................................... ................................ 187 14.0 ssp module overview ........................................................................................................ ..................................................... 193 15.0 capture/compare/pwm (ccp) module ........................................................................................... ........................................ 211 16.0 special features of the cpu................................................................................................ .................................................... 219 17.0 instruction set summary .................................................................................................... ...................................................... 241 18.0 development support........................................................................................................ ....................................................... 251 19.0 electrical specifications.................................................................................................. .......................................................... 255 20.0 dc and ac characteristics graphs and tables................................................................................ ....................................... 283 21.0 packaging information...................................................................................................... ........................................................ 305 appendix a: data sheet revision history........................................................................................ .................................................. 315 appendix b: migrating from other pic ? devices....................................................................................................................... ....... 315 appendix c: conversion considerations .......................................................................................... ................................................. 316 index .......................................................................................................................... ........................................................................ 317 the microchip web site ......................................................................................................... ............................................................ 325 customer change notification service ........................................................................................... ................................................... 325 customer support............................................................................................................... ............................................................... 325 reader response ................................................................................................................ .............................................................. 327 product identification system .................................................................................................. .......................................................... 328 to our valued customers it is our intention to provide our valued customers with the best documentation possible to ensure successful use of your micro chip products. to this end, we will continue to improve our publications to better suit your needs. our publications will be refined and enhanced as new volumes and updates are introduced. if you have any questions or comments regar ding this publication, please contact the marketing communications department via e-mail at docerrors@microchip.com or fax the reader response form in the back of this data sheet to (480) 792-4150. we welcome your feedback. most current data sheet to obtain the most up-to-date version of this data s heet, please register at our worldwide web site at: http://www.microchip.com you can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page . the last character of the literature number is the vers ion number, (e.g., ds30000a is version a of document ds30000). errata an errata sheet, describing minor operational differences fr om the data sheet and recommended workarounds, may exist for curren t devices. as device/documentation issues become known to us, we will publish an errata sheet. the errata will specify the revisi on of silicon and revision of document to which it applies. to determine if an errata sheet exists for a particular device, please check with one of the following: ? microchip?s worldwide web site; http://www.microchip.com ? your local microchip sales office (see last page) when contacting a sales office, please specify which device, re vision of silicon and data sheet (include literature number) you are using. customer notification system register on our web site at www.microchip.com to receive the most current information on all of our products.
pic16f913/914/916/917/946 ds41250f-page 14 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 15 pic16f913/914/916/917/946 1.0 device overview the pic16f91x/946 devices are covered by this data sheet. they are available in 28/40/44/64-pin packages. figure 1-1 shows a block diagram of the pic16f913/916 device, figure 1-2 shows a block diagram of the pic16F914/917 device, and figure 1-3 shows a block diagram of the pic16f946 device. table 1-1 shows the pinout descriptions. figure 1-1: pic16f91 3/916 block diagram power-up timer oscillator start-up timer power-on reset watchdog timer brown-out reset rb0 rb1 rb2 rb3 rb4 rb5 rb6 rb7 flash program memory 13 data bus 8 14 program bus instruction reg program counter ram file registers direct addr 7 ram addr 9 addr mux indirect addr fsr reg status reg mux alu w reg instruction decode and control timing generation osc1/clkin osc2/clkout porta 8 8 8 3 8-level stack (13-bit) 256/352 bytes 4k/8k x 14 v ss ra0 ra1 ra2 ra3 ra4 ra5 ra7 int configuration internal oscillator v dd block program memory read portc rc0 rc1 rc2 rc3 rc4 rc5 rc6 rc7 porte re3/mclr (pmr) portb plvd lcd data eeprom 256 bytes comparators addressable usart ccp1 ssp timer0 timer1 timer2 10-bit a/d
pic16f913/914/916/917/946 ds41250f-page 16 ? 2007 microchip technology inc. figure 1-2: pic16f91 4/917 block diagram portd rd0 rd1 rd2 rd3 rd4 rd5 rd6 rd7 power-up timer oscillator start-up timer power-on reset watchdog timer brown-out reset portb rb0 rb1 rb2 rb3 rb4 rb5 rb6 rb7 flash program memory 13 data bus 8 14 program bus instruction reg program counter ram file registers direct addr 7 ram addr 9 addr mux indirect addr fsr reg status reg mux alu w reg instruction decode and control timing generation osc1/clkin osc2/clkout porta 8 8 8 3 8-level stack (13-bit) 256/352 bytes 4k/8k x 14 v ss ra0 ra1 ra2 ra3 ra4 ra5 ra6 ra7 int configuration internal oscillator v dd block program memory read data eeprom 256 bytes portc rc0 rc1 rc2 rc3 rc4 rc5 rc6 rc7 porte (pmr) re0 re1 re2 re3/mclr plvd lcd comparators addressable usart ccp2 ssp timer0 timer1 timer2 10-bit a/d ccp1
? 2007 microchip technology inc. ds41250f-page 17 pic16f913/914/916/917/946 figure 1-3: pic16f 946 block diagram power-up timer oscillator start-up timer power-on reset watchdog timer brown-out reset rb0 rb1 rb2 rb3 rb4 rb5 rb6 rb7 flash program memory 13 data bus 8 14 program bus instruction reg program counter ram file registers direct addr 7 ram addr 9 addr mux indirect addr fsr reg status reg mux alu w reg instruction decode and control timing generation osc1/clkin osc2/clkout porta 8 8 8 3 8-level stack (13-bit) 336 x 8 bytes 8k x 14 v ss ra0 ra1 ra2 ra3 ra4 ra5 ra6 ra7 configuration internal oscillator v dd block program memory read portc rc0 rc1 rc2 rc3 rc4 rc5 rc6 rc7 portd (pmr) portb plvd lcd data eeprom 256 bytes comparators ssp ccp1 ccp2 timer0 timer1 timer2 10-bit a/d addressable usart porte portf portg rd0 rd1 rd2 rd3 rd4 rd5 rd6 rd7 re0 re1 re2 re3/mclr re4 re5 re6 re7 rf0 rf1 rf2 rf3 rf4 rf5 rf6 rf7 rg0 rg1 rg2 rg3 rg4 rg5 int av ss av dd
pic16f913/914/916/917/946 ds41250f-page 18 ? 2007 microchip technology inc. table 1-1: pic16f91x/946 pinout descriptions name function input type output type description ra0/an0/c1-/seg12 ra0 ttl cmos general purpose i/o. an0 an ? analog input channel 0. c1- an ? comparator 1 negative input. seg12 ? an lcd analog output. ra1/an1/c2-/seg7 ra1 ttl cmos general purpose i/o. an1 an ? analog input channel 1. c2- an ? comparator 2 negative input. seg7 ? an lcd analog output. ra2/an2/c2+/v ref -/com2 ra2 ttl cmos general purpose i/o. an2 an ? analog input channel 2. c2+ an ? comparator 2 positive input. v ref - an ? external a/d voltage reference ? negative. com2 ? an lcd analog output. ra3/an3/c1+/v ref +/com3 (1) / seg15 ra3 ttl cmos general purpose i/o. an3 an ? analog input channel 3. c1+ an ? comparator 1 positive input. v ref + an ? external a/d voltage reference ? positive. com3 (1) ? an lcd analog output. seg15 ? an lcd analog output. ra4/c1out/t0cki/seg4 ra4 ttl cmos general purpose i/o. c1out ? cmos comparator 1 output. t0cki st ? timer0 clock input. seg4 ? an lcd analog output. ra5/an4/c2out/ss /seg5 ra5 ttl cmos general purpose i/o. an4 an ? analog input channel 4. c2out ? cmos comparator 2 output. ss ttl ? slave select input. seg5 ? an lcd analog output. ra6/osc2/clkout/t1oso ra6 ttl cmos general purpose i/o. osc2 ? xtal crystal/resonator. clkout ? cmos t osc /4 reference clock. t1oso ? xtal timer1 oscillator output. ra7/osc1/clkin/t1osi ra7 ttl cmos general purpose i/o. osc1 xtal ? crystal/resonator. clkin st ? clock input. t1osi xtal ? timer1 oscillator input. rb0/int/seg0 rb0 ttl cmos general purpose i/o. individually enabled pull-up. int st ? external interrupt pin. seg0 ? an lcd analog output. legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels p = power hv = high voltage xtal = crystal note 1: com3 is available on ra3 for the pic16f913/916 and on rd0 for the pic16F914/917 and pic16f946. 2: pins available on pic16F914/917 and pic16f946 only. 3: pins available on pic16f946 only. 4: i 2 c schmitt trigger inputs have special input levels.
? 2007 microchip technology inc. ds41250f-page 19 pic16f913/914/916/917/946 rb1/seg1 rb1 ttl cmos general purpose i/o. individually enabled pull-up. seg1 ? an lcd analog output. rb2/seg2 rb2 ttl cmos general purpose i/o. individually enabled pull-up. seg2 ? an lcd analog output. rb3/seg3 rb3 ttl cmos general purpose i/o. individually enabled pull-up. seg3 ? an lcd analog output. rb4/com0 rb4 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. com0 ? an lcd analog output. rb5/com1 rb5 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. com1 ? an lcd analog output. rb6/icspclk/icdck/seg14 rb6 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. icspclk st ? icsp? clock. icdck st ? icd clock. seg14 ? an lcd analog output. rb7/icspdat/icddat/seg13 rb7 ttl cmos general purpose i/o. individually controlled inter- rupt-on-change. individually enabled pull-up. icspdat st cmos icsp data i/o. icddat st cmos icd data i/o. seg13 ? an lcd analog output. rc0/vlcd1 rc0 st cmos general purpose i/o. vlcd1 an ? lcd analog input. rc1/vlcd2 rc1 st cmos general purpose i/o. vlcd2 an ? lcd analog input. rc2/vlcd3 rc2 st cmos general purpose i/o. vlcd3 an ? lcd analog input. rc3/seg6 rc3 st cmos general purpose i/o. seg6 ? an lcd analog output. rc4/t1g /sdo/seg11 rc4 st cmos general purpose i/o. t1g st ? timer1 gate input. sdo ? cmos serial data output. seg11 ? an lcd analog output. rc5/t1cki/ccp1/seg10 rc5 st cmos general purpose i/o. t1cki st ? timer1 clock input. ccp1 st cmos capture 1 input/compare 1 output/pwm 1 output. seg10 ? an lcd analog output. table 1-1: pic16f91x/946 pinout descriptions (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels p = power hv = high voltage xtal = crystal note 1: com3 is available on ra3 for the pic16f913/916 and on rd0 for the pic16F914/917 and pic16f946. 2: pins available on pic16F914/917 and pic16f946 only. 3: pins available on pic16f946 only. 4: i 2 c schmitt trigger inputs have special input levels.
pic16f913/914/916/917/946 ds41250f-page 20 ? 2007 microchip technology inc. rc6/tx/ck/sck/scl/seg9 rc6 st cmos general purpose i/o. tx ? cmos usart asynchronous serial transmit. ck st cmos usart synchronous serial clock. sck st cmos spi clock. scl st (4) od i 2 c? clock. seg9 ? an lcd analog output. rc7/rx/dt/sdi/sda/seg8 rc7 st cmos general purpose i/o. rx st ? usart asynchronous serial receive. dt st cmos usart synchronous serial data. sdi st cmos spi data input. sda st (4) od i 2 c? data. seg8 ? an lcd analog output. rd0/com3 (1, 2) rd0 st cmos general purpose i/o. com3 ? an lcd analog output. rd1 (2) rd1 st cmos general purpose i/o. rd2/ccp2 (2) rd2 st cmos general purpose i/o. ccp2 st cmos capture 2 input/compare 2 output/pwm 2 output. rd3/seg16 (2) rd3 st cmos general purpose i/o. seg16 ? an lcd analog output. rd4/seg17 (2) rd4 st cmos general purpose i/o. seg17 ? an lcd analog output. rd5/seg18 (2) rd5 st cmos general purpose i/o. seg18 ? an lcd analog output. rd6/seg19 (2) rd6 st cmos general purpose i/o. seg19 ? an lcd analog output. rd7/seg20 (2) rd7 st cmos general purpose i/o. seg20 ? an lcd analog output. re0/an5/seg21 (2) re0 st cmos general purpose i/o. an5 an ? analog input channel 5. seg21 ? an lcd analog output. re1/an6/seg22 (2) re1 st cmos general purpose i/o. an6 an ? analog input channel 6. seg22 ? an lcd analog output. re2/an7/seg23 (2) re2 st cmos general purpose i/o. an7 an ? analog input channel 7. seg23 ? an lcd analog output. re3/mclr /v pp re3 st ? digital input only. mclr st ? master clear with internal pull-up. v pp hv ? programming voltage. table 1-1: pic16f91x/946 pinout descriptions (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels p = power hv = high voltage xtal = crystal note 1: com3 is available on ra3 for the pic16f913/916 and on rd0 for the pic16F914/917 and pic16f946. 2: pins available on pic16F914/917 and pic16f946 only. 3: pins available on pic16f946 only. 4: i 2 c schmitt trigger inputs have special input levels.
? 2007 microchip technology inc. ds41250f-page 21 pic16f913/914/916/917/946 re4/seg24 (3) re4 st cmos general purpose i/o. seg24 ? an lcd analog output. re5/seg25 (3) re5 st cmos general purpose i/o. seg25 ? an lcd analog output. re6/seg26 (3) re6 st cmos general purpose i/o. seg26 ? an lcd analog output. re7/seg27 (3) re7 st cmos general purpose i/o. seg27 ? an lcd analog output. rf0/seg32 (3) rf0 st cmos general purpose i/o. seg32 ? an lcd analog output. rf1/seg33 (3) rf1 st cmos general purpose i/o. seg33 ? an lcd analog output. rf2/seg34 (3) rf2 st cmos general purpose i/o. seg34 ? an lcd analog output. rf3/seg35 (3) rf3 st cmos general purpose i/o. seg35 ? an lcd analog output. rf4/seg28 (3) rf4 st cmos general purpose i/o. seg28 ? an lcd analog output. rf5/seg29 (3) rf5 st cmos general purpose i/o. seg29 ? an lcd analog output. rf6/seg30 (3) rf6 st cmos general purpose i/o. seg30 ? an lcd analog output. rf7/seg31 (3) rf7 st cmos general purpose i/o. seg31 ? an lcd analog output. rg0/seg36 (3) rg0 st cmos general purpose i/o. seg36 ? an lcd analog output. rg1/seg37 (3) rg1 st cmos general purpose i/o. seg37 ? an lcd analog output. rg2/seg38 (3) rg2 st cmos general purpose i/o. seg38 ? an lcd analog output. rg3/seg39 (3) rg3 st cmos general purpose i/o. seg39 ? an lcd analog output. rg4/seg40 (3) rg4 st cmos general purpose i/o. seg10 ? an lcd analog output. rg5/seg41 (3) rg5 st cmos general purpose i/o. seg41 ? an lcd analog output. av dd (3) av dd p ? analog power supply for microcontroller. av ss (3) av ss p ? analog ground reference for microcontroller. v dd v dd p ? power supply for microcontroller. table 1-1: pic16f91x/946 pinout descriptions (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels p = power hv = high voltage xtal = crystal note 1: com3 is available on ra3 for the pic16f913/916 and on rd0 for the pic16F914/917 and pic16f946. 2: pins available on pic16F914/917 and pic16f946 only. 3: pins available on pic16f946 only. 4: i 2 c schmitt trigger inputs have special input levels.
pic16f913/914/916/917/946 ds41250f-page 22 ? 2007 microchip technology inc. v ss v ss p ? ground reference for microcontroller. table 1-1: pic16f91x/946 pinout descriptions (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels p = power hv = high voltage xtal = crystal note 1: com3 is available on ra3 for the pic16f913/916 and on rd0 for the pic16F914/917 and pic16f946. 2: pins available on pic16F914/917 and pic16f946 only. 3: pins available on pic16f946 only. 4: i 2 c schmitt trigger inputs have special input levels.
? 2007 microchip technology inc. ds41250f-page 23 pic16f913/914/916/917/946 2.0 memory organization 2.1 program memory organization the pic16f91x/946 has a 13-bit program counter capable of addressing a 4k x 14 program memory space for the pic16f913/914 (0000h-0fffh) and an 8k x 14 program memory space for the pic16f916/ 917 and pic16f946 (0000h-1fffh). accessing a location above the memory boundaries for the pic16f913 and pic16F914 will cause a wrap around within the first 4k x 14 space. the reset vector is at 0000h and the interrupt vector is at 0004h. figure 2-1: program memory map and stack for the pic16f913/914 figure 2-2: program memory map and stack for the pic16f916/917/pic16f946 pc<12:0> 13 0000h 0004h stack level 1 stack level 8 reset vector interrupt vector call, return retfie, retlw stack level 2 0005h on-chip 1fffh program memory page 0 page 1 07ffh 0800h 0fffh 1000h pc<12:0> 13 0000h 0004h stack level 1 stack level 8 reset vector interrupt vector call, return retfie, retlw stack level 2 0005h on-chip 1fffh program memory page 0 page 1 page 2 page 3 07ffh 0800h 0fffh 1000h 17ffh 1800h
pic16f913/914/916/917/946 ds41250f-page 24 ? 2007 microchip technology inc. 2.2 data memory organization the data memory is partitioned into multiple banks which contain the general purpose registers (gprs) and the special function registers (sfrs). bits rp0 and rp1 are bank select bits. rp1 rp0 00 bank 0 is selected 01 bank 1 is selected 10 bank 2 is selected 11 bank 3 is selected each bank extends up to 7fh (128 bytes). the lower locations of each bank are reserved for the special function registers. above the special function registers are the general purpose registers, implemented as static ram. all implemented banks contain special function registers. some frequently used special function registers from one bank are mirrored in another bank for code reduction and quicker access. 2.2.1 general purpose register file the register file is organized as 256 x 8 bits in the pic16f913/914, 352 x 8 bits in the pic16f916/917 and 336 x 8 bits in the pic16f946. each register is accessed either directly or indirectly through the file select register (fsr) (see section 2.5 ?indirect addressing, indf and fsr registers? ). 2.2.2 special function registers the special function registers are registers used by the cpu and peripheral functions for controlling the desired operation of the device (see tables 2-1, 2-2, 2-3 and 2-4). these registers are static ram. the special function registers can be classified into two sets: core and peripheral. the special function registers associated with the ?core? are described in this section. those related to the operation of the peripheral features are described in the section of that peripheral feature.
? 2007 microchip technology inc. ds41250f-page 25 pic16f913/914/916/917/946 figure 2-3: pic16f913/916 special function registers file file file file address address address address indirect addr. (1) 00h indirect addr. (1) 80h indirect addr. (1) 100h indirect addr. (1) 180h tmr0 01h option_reg 81h tmr0 101h option_reg 181h pcl 02h pcl 82h pcl 102h pcl 182h status 03h status 83h status 103h status 183h fsr 04h fsr 84h fsr 104h fsr 184h porta 05h trisa 85h wdtcon 105h 185h portb 06h trisb 86h portb 106h trisb 186h portc 07h trisc 87h lcdcon 107h 187h 08h 88h lcdps 108h 188h porte 09h trise 89h lvdcon 109h 189h pclath 0ah pclath 8ah pclath 10ah pclath 18ah intcon 0bh intcon 8bh intcon 10bh intcon 18bh pir1 0ch pie1 8ch eedatl 10ch eecon1 18ch pir2 0dh pie2 8dh eeadrl 10dh eecon2 (1) 18dh tmr1l 0eh pcon 8eh eedath 10eh reserved 18eh tmr1h 0fh osccon 8fh eeadrh 10fh reserved 18fh t1con 10h osctune 90h lcddata0 110h general purpose register (2) 96 bytes 190h tmr2 11h ansel 91h lcddata1 111h t2con 12h pr2 92h 112h sspbuf 13h sspadd 93h lcddata3 113h sspcon 14h sspstat 94h lcddata4 114h ccpr1l 15h wpub 95h 115h ccpr1h 16h iocb 96h lcddata6 116h ccp1con 17h cmcon1 97h lcddata7 117h rcsta 18h txsta 98h 118h txreg 19h spbrg 99h lcddata9 119h rcreg 1ah 9ah lcddata10 11ah 1bh 9bh 11bh 1ch cmcon0 9ch lcdse0 11ch 1dh vrcon 9dh lcdse1 11dh adresh 1eh adresl 9eh 11eh adcon0 1fh adcon1 9fh 11fh general purpose register 96 bytes 20h general purpose register 80 bytes a0h general purpose register 80 bytes 120h efh 16fh 1efh accesses 70h-7fh f0h accesses 70h-7fh 170h accesses 70h-7fh 1f0h 7fh ffh 17fh 1ffh bank 0 bank 1 bank 2 bank 3 unimplemented data memory locations, read as ? 0 ?. note 1: not a physical register. 2: on the pic16f913, unimplemented data memory locations, read as ? 0 ?.
pic16f913/914/916/917/946 ds41250f-page 26 ? 2007 microchip technology inc. figure 2-4: pic16F914/917 special function registers file file file file address address address address indirect addr. (1) 00h indirect addr. (1) 80h indirect addr. (1) 100h indirect addr. (1) 180h tmr0 01h option_reg 81h tmr0 101h option_reg 181h pcl 02h pcl 82h pcl 102h pcl 182h status 03h status 83h status 103h status 183h fsr 04h fsr 84h fsr 104h fsr 184h porta 05h trisa 85h wdtcon 105h 185h portb 06h trisb 86h portb 106h trisb 186h portc 07h trisc 87h lcdcon 107h 187h portd 08h trisd 88h lcdps 108h 188h porte 09h trise 89h lvdcon 109h 189h pclath 0ah pclath 8ah pclath 10ah pclath 18ah intcon 0bh intcon 8bh intcon 10bh intcon 18bh pir1 0ch pie1 8ch eedatl 10ch eecon1 18ch pir2 0dh pie2 8dh eeadrl 10dh eecon2 (1) 18dh tmr1l 0eh pcon 8eh eedath 10eh reserved 18eh tmr1h 0fh osccon 8fh eeadrh 10fh reserved 18fh t1con 10h osctune 90h lcddata0 110h general purpose register (2) 96 bytes 190h tmr2 11h ansel 91h lcddata1 111h t2con 12h pr2 92h lcddata2 112h sspbuf 13h sspadd 93h lcddata3 113h sspcon 14h sspstat 94h lcddata4 114h ccpr1l 15h wpub 95h lcddata5 115h ccpr1h 16h iocb 96h lcddata6 116h ccp1con 17h cmcon1 97h lcddata7 117h rcsta 18h txsta 98h lcddata8 118h txreg 19h spbrg 99h lcddata9 119h rcreg 1ah 9ah lcddata10 11ah ccpr2l 1bh 9bh lcddata11 11bh ccpr2h 1ch cmcon0 9ch lcdse0 11ch ccp2con 1dh vrcon 9dh lcdse1 11dh adresh 1eh adresl 9eh lcdse2 11eh adcon0 1fh adcon1 9fh 11fh general purpose register 96 bytes 20h general purpose register 80 bytes a0h general purpose register 80 bytes 120h efh 16fh 1efh accesses 70h-7fh f0h accesses 70h-7fh 170h accesses 70h-7fh 1f0h 7fh ffh 17fh 1ffh bank 0 bank 1 bank 2 bank 3 unimplemented data memory locations, read as ? 0 ?. note 1: not a physical register. 2: on the pic16F914, unimplemented data memory locations, read as ? 0 ?.
? 2007 microchip technology inc. ds41250f-page 27 pic16f913/914/916/917/946 figure 2-5: pic16f946 special function registers file file file file address address address address indirect addr. (1) 00h indirect addr. (1) 80h indirect addr. (1) 100h indirect addr. (1) 180h tmr0 01h option_reg 81h tmr0 101h option_reg 181h pcl 02h pcl 82h pcl 102h pcl 182h status 03h status 83h status 103h status 183h fsr 04h fsr 84h fsr 104h fsr 184h porta 05h trisa 85h wdtcon 105h trisf 185h portb 06h trisb 86h portb 106h trisb 186h portc 07h trisc 87h lcdcon 107h trisg 187h portd 08h trisd 88h lcdps 108h portf 188h porte 09h trise 89h lvdcon 109h portg 189h pclath 0ah pclath 8ah pclath 10ah pclath 18ah intcon 0bh intcon 8bh intcon 10bh intcon 18bh pir1 0ch pie1 8ch eedatl 10ch eecon1 18ch pir2 0dh pie2 8dh eeadrl 10dh eecon2 (1) 18dh tmr1l 0eh pcon 8eh eedath 10eh reserved 18eh tmr1h 0fh osccon 8fh eeadrh 10fh reserved 18fh t1con 10h osctune 90h lcddata0 110h lcddata12 190h tmr2 11h ansel 91h lcddata1 111h lcddata13 191h t2con 12h pr2 92h lcddata2 112h lcddata14 192h sspbuf 13h sspadd 93h lcddata3 113h lcddata15 193h sspcon 14h sspstat 94h lcddata4 114h lcddata16 194h ccpr1l 15h wpub 95h lcddata5 115h lcddata17 195h ccpr1h 16h iocb 96h lcddata6 116h lcddata18 196h ccp1con 17h cmcon1 97h lcddata7 117h lcddata19 197h rcsta 18h txsta 98h lcddata8 118h lcddata20 198h txreg 19h spbrg 99h lcddata9 119h lcddata21 199h rcreg 1ah 9ah lcddata10 11ah lcddata22 19ah ccpr2l 1bh 9bh lcddata11 11bh lcddata23 19bh ccpr2h 1ch cmcon0 9ch lcdse0 11ch lcdse3 19ch ccp2con 1dh vrcon 9dh lcdse1 11dh lcdse4 19dh adresh 1eh adresl 9eh lcdse2 11eh lcdse5 19eh adcon0 1fh adcon1 9fh 11fh 19fh general purpose register 96 bytes 20h general purpose register 80 bytes a0h general purpose register 80 bytes 120h general purpose register 80 bytes 1a0h efh 16fh 1efh accesses 70h-7fh f0h accesses 70h-7fh 170h accesses 70h-7fh 1f0h 7fh ffh 17fh 1ffh bank 0bank 1bank 2bank 3 unimplemented data memory locations, read as ? 0 ?. note 1: not a physical register.
pic16f913/914/916/917/946 ds41250f-page 28 ? 2007 microchip technology inc. table 2-1: pic16f91x/946 special function registers summary bank 0 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor page bank 0 00h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 41,226 01h tmr0 timer0 module register xxxx xxxx 99,226 02h pcl program counter?s (pc) least significant byte 0000 0000 40,226 03h status irp rp1 rp0 to pd zdcc 0001 1xxx 32,226 04h fsr indirect data memory address pointer xxxx xxxx 41,226 05h porta ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 xxxx xxxx 44,226 06h portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx xxxx 54,226 07h portc rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 xxxx xxxx 62,226 08h portd (2) rd7 rd6 rd5 rd4 rd3 rd2 rd1 rd0 xxxx xxxx 71,226 09h porte re7 (3) re6 (3) re5 (3) re4 (3) re3 re2 (2) re1 (2) re0 (2) xxxx xxxx 76,226 0ah pclath ? ? ? write buffer for upper 5 bits of program counter ---0 0000 40,226 0bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 34,226 0ch pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 37,226 0dh pir2 osfif c2if c1if lcdif ?lvdif ? ccp2if (2) 0000 -0-0 38,226 0eh tmr1l holding register for the least significant byte of the 16-bit tmr1 xxxx xxxx 102,226 0fh tmr1h holding register for the most significant byte of the 16-bit tmr1 xxxx xxxx 102,226 10h t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 105,226 11h tmr2 timer2 module register 0000 0000 107,226 12h t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 108,226 13h sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx 196,226 14h sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 195,226 15h ccpr1l capture/compare/pwm register 1 (lsb) xxxx xxxx 213,226 16h ccpr1h capture/compare/pwm register 1 (msb) xxxx xxxx 213,226 17h ccp1con ? ? ccp1x ccp1y ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 212,226 18h rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 131,226 19h txreg usart transmit data register 0000 0000 130,226 1ah rcreg usart receive data register 0000 0000 128,227 1bh (2) ccpr2l capture/compare/pwm register 2 (lsb) xxxx xxxx 213,227 1ch (2) ccpr2h capture/compare/pwm register 2 (msb) xxxx xxxx 213,227 1dh (2) ccp2con ? ? ccp2x ccp2y ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 212,227 1eh adresh a/d result register high byte xxxx xxxx 182,227 1fh adcon0 adfm vcfg1 vcfg0 chs2 chs1 chs0 go/done adon 0000 0000 180,227 legend: - = unimplemented locations read as ? 0 ?, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: pic16F914/917 and pic16f946 only, forced ? 0 ? on pic16f913/916. 3: pic16f946 only, forced to ? 0 ? on pic16f91x.
? 2007 microchip technology inc. ds41250f-page 29 pic16f913/914/916/917/946 table 2-2: pic16f91x/946 special function registers summary bank 1 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor page bank 1 80h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 41,226 81h option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 33,227 82h pcl program counter?s (pc) least significant byte 0000 0000 40,226 83h status irp rp1 rp0 to pd zdcc 0001 1xxx 32,226 84h fsr indirect data memory address pointer xxxx xxxx 41,226 85h trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 44,227 86h trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 54,227 87h trisc trisc7 trisc6 trisc5 tr isc4 trisc3 trisc2 trisc1 trisc0 1111 1111 62,227 88h trisd (3) trisd7 trisd6 trisd5 trisd4 trisd3 trisd2 trisd1 trisd0 1111 1111 71,227 89h trise trise7 (2) trise6 (2) trise5 (2) trise4 (2) trise3 (5) trise2 (3) trise1 (3) trise0 (3) 1111 1111 76,227 8ah pclath ? ? ? write buffer for the upper 5 bits of the program counter ---0 0000 40,226 8bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 34,226 8ch pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 35,227 8dh pie2 osfie c2ie c1ie lcdie ?lvdie ? ccp2ie (3) 0000 -0-0 36,227 8eh pcon ? ? ? sboren ? ?por bor ---1 --qq 39,227 8fh osccon ? ircf2 ircf1 ircf0 osts (4) hts lts scs -110 q000 88,227 90h osctune ? ? ? tun4 tun3 tun2 tun1 tun0 ---0 0000 92,227 91h ansel ans7 (3) ans6 (3) ans5 (3) ans4 ans3 ans2 ans1 ans0 1111 1111 43,227 92h pr2 timer2 period register 1111 1111 107,227 93h sspadd synchronous serial port (i 2 c mode) address register 0000 0000 202,227 94h sspstat smp cke d/a psr/w ua bf 0000 0000 194,227 95h wpub wpub7 wpub6 wpub5 wpub4 wpub3 wpub2 wpub1 wpub0 1111 1111 55,227 96h iocb iocb7 iocb6 iocb5 iocb4 ? ? ? ? 0000 ---- 54,227 97h cmcon1 ? ? ? ? ? ? t1gss c2sync ---- --10 117,227 98h txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 130,227 99h spbrg spbrg7 spbrg6 spbrg5 spbrg4 spbrg3 spbrg2 spbrg1 spbrg0 0000 0000 132,227 9ah ? unimplemented ? ? 9bh ? unimplemented ? ? 9ch cmcon0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 116,227 9dh vrcon vren ?vrr ? vr3 vr2 vr1 vr0 0-0- 0000 118,227 9eh adresl a/d result register low byte xxxx xxxx 182,227 9fh adcon1 ? adcs2 adcs1 adcs0 ? ? ? ? -000 ---- 181,227 legend: - = unimplemented locations read as ? 0 ?, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: pic16f946 only, forced ? 0 ? on pic16f91x. 3: pic16F914/917 and pic16f946 only, forced ? 0 ? on pic16f913/916. 4: the value of the osts bit is dependent on the value of the configuration word (config) of the device. see section 4.2 ?oscillator control? . 5: bit is read-only; trise3 = 1 always.
pic16f913/914/916/917/946 ds41250f-page 30 ? 2007 microchip technology inc. table 2-3: pic16f91x/946 special function registers summary bank 2 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor page bank 2 100h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 41,226 101h tmr0 timer0 module register xxxx xxxx 99,226 102h pcl program counter?s (pc) least significant byte 0000 0000 40,226 103h status irp rp1 rp0 to pd zdcc 0001 1xxx 32,226 104h fsr indirect data memory address pointer xxxx xxxx 41,226 105h wdtcon ? ? ? wdtps3 wdtps2 wdtps1 wdtps0 swdten ---0 1000 235,227 106h portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx xxxx 54,226 107h lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 145,227 108h lcdps wft biasmd lcda wa lp3 lp2 lp1 lp0 0000 0000 146,227 109h lvdcon ? ?irvstlvden ? lvdl2 lvdl1 lvdl0 --00 -100 145,228 10ah pclath ? ? ? write buffer for the upper 5 bits of the program counter ---0 0000 40,226 10bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 34,226 10ch eedatl eedatl7 eedatl6 eedatl5 eedatl4 eedatl3 eedatl2 eedatl1 eedatl0 0000 0000 188,228 10dh eeadrl eeadrl7 eeadrl6 eeadrl5 eeadrl4 eeadrl3 eeadrl2 eeadrl1 eeadrl0 0000 0000 188,228 10eh eedath ? ? eedath5 eedath4 eedath3 eedath2 eedath1 eedath0 --00 0000 188,228 10fh eeadrh ? ? ? eeadrh4 eeadrh3 eeadrh2 eeadrh1 eeadrh0 ---0 0000 188,228 110h lcddata0 seg7 com0 seg6 com0 seg5 com0 seg4 com0 seg3 com0 seg2 com0 seg1 com0 seg0 com0 xxxx xxxx 147,228 111h lcddata1 seg15 com0 seg14 com0 seg13 com0 seg12 com0 seg11 com0 seg10 com0 seg9 com0 seg8 com0 xxxx xxxx 147,228 112h lcddata2 (2) seg23 com0 seg22 com0 seg21 com0 seg20 com0 seg19 com0 seg18 com0 seg17 com0 seg16 com0 xxxx xxxx 147,228 113h lcddata3 seg7 com1 seg6 com1 seg5 com1 seg4 com1 seg3 com1 seg2 com1 seg1 com1 seg0 com1 xxxx xxxx 147,228 114h lcddata4 seg15 com1 seg14 com1 seg13 com1 seg12 com1 seg11 com1 seg10 com1 seg9 com1 seg8 com1 xxxx xxxx 147,228 115h lcddata5 (2) seg23 com1 seg22 com1 seg21 com1 seg20 com1 seg19 com1 seg18 com1 seg17 com1 seg16 com1 xxxx xxxx 147,228 116h lcddata6 seg7 com2 seg6 com2 seg5 com2 seg4 com2 seg3 com2 seg2 com2 seg1 com2 seg0 com2 xxxx xxxx 147,228 117h lcddata7 seg15 com2 seg14 com2 seg13 com2 seg12 com2 seg11 com2 seg10 com2 seg9 com2 seg8 com2 xxxx xxxx 147,228 118h lcddata8 (2) seg23 com2 seg22 com2 seg21 com2 seg20 com2 seg19 com2 seg18 com2 seg17 com2 seg16 com2 xxxx xxxx 147,228 119h lcddata9 seg7 com3 seg6 com3 seg5 com3 seg4 com3 seg3 com3 seg2 com3 seg1 com3 seg0 com3 xxxx xxxx 147,228 11ah lcddata10 seg15 com3 seg14 com3 seg13 com3 seg12 com3 seg11 com3 seg10 com3 seg9 com3 seg8 com3 xxxx xxxx 147,228 11bh lcddata11 (2) seg23 com3 seg22 com3 seg21 com3 seg20 com3 seg19 com3 seg18 com3 seg17 com3 seg16 com3 xxxx xxxx 147,228 11ch lcdse0 (3) se7 se6 se5 se4 se3 se2 se1 se0 0000 0000 147,228 11dh lcdse1 (3) se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 147,228 11eh lcdse2 (2,3) se23 se22 se21 se20 se19 se18 se17 se16 0000 0000 147,228 11fh ? unimplemented ? ? legend: ? = unimplemented locations read as ? 0 ?, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: pic16F914/917 and pic16f946 only. 3: this register is only initialized by a por or bor reset and is unchanged by other resets.
? 2007 microchip technology inc. ds41250f-page 31 pic16f913/914/916/917/946 table 2-4: pic16f91x/946 special function registers summary bank 3 addr name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor page bank 3 180h indf addressing this location uses contents of fsr to address data memory (not a physical register) xxxx xxxx 41,226 181h option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 33,227 182h pcl program counter (pc) least significant byte 0000 0000 40,226 183h status irp rp1 rp0 to pd zdcc 0001 1xxx 32,226 184h fsr indirect data memory address pointer xxxx xxxx 41,226 185h trisf (3) trisf7 trisf6 trisf5 trisf4 trisf3 trisf2 trisf1 trisf0 1111 1111 81,228 186h trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 54,227 187h trisg (3) ? ? trisg5 trisg4 trisg3 t risg2 trisg1 trisg0 --11 1111 84,228 188h portf (3) rf7 rf6 rf5 rf4 rf3 rf2 rf1 rf0 xxxx xxxx 81,228 189h portg (3) ? ? rg5 rg4 rg3 rg2 rg1 rg0 --xx xxxx 84,228 18ah pclath ? ? ? write buffer for the upper 5 bits of the program counter ---0 0000 40,226 18bh intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 34,226 18ch eecon1 eepgd ? ? ? wrerr wren wr rd 0--- x000 189,229 18dh eecon2 eeprom control register 2 (not a physical register) ---- ---- 187 18eh ? reserved ? ? 18fh ? reserved ? ? 190h lcddata12 (3) seg31 com0 seg30 com0 seg29 com0 seg28 com0 seg27 com0 seg26 com0 seg25 com0 seg24 com0 xxxx xxxx 147,228 191h lcddata13 (3) seg39 com0 seg38 com0 seg37 com0 seg36 com0 seg35 com0 seg34 com0 se33 com0 seg32 com0 xxxx xxxx 147,228 192h lcddata14 (3) ? ? ? ? ? ?seg41 com0 seg40 com0 ---- --xx 147,228 193h lcddata15 (3) seg31 com1 seg30 com1 seg29 com1 seg28 com1 seg27 com1 seg26 com1 seg25 com1 seg24 com1 xxxx xxxx 147,228 194h lcddata16 (3) seg39 com1 seg38 com1 seg37 com1 seg36 com1 seg35 com1 seg34 com1 seg33 com1 seg32 com1 xxxx xxxx 147,228 195h lcddata17 (3) ? ? ? ? ? ?seg41 com1 seg40 com1 ---- --xx 147,228 196h lcddata18 (3) seg31 com2 seg30 com2 seg29 com2 seg28 com2 seg27 com2 seg26 com2 seg25 com2 seg24 com2 xxxx xxxx 147,228 197h lcddata19 (3) seg39 com2 seg38 com2 seg37 com2 seg36 com2 seg35 com2 seg34 com2 seg33 com2 seg32 com2 xxxx xxxx 147,228 198h lcddata20 (3) ? ? ? ? ? ?seg41 com2 seg40 com2 ---- --xx 147,228 199h lcddata21 (3) seg31 com3 seg30 com3 seg29 com3 seg28 com3 seg27 com3 seg26 com3 seg25 com3 seg24 com3 xxxx xxxx 147,228 19ah lcddata22 (3) seg39 com3 seg38 com3 seg37 com3 seg36 com3 seg35 com3 seg34 com3 seg33 com3 seg32 com3 xxxx xxxx 147,228 19bh lcddata23 (3) ? ? ? ? ? ?seg41 com3 seg40 com3 ---- --xx 147,228 19ch lcdse3 (2, 3) se31 se30 se29 se28 se27 se26 se25 se24 0000 0000 147,229 19dh lcdse4 (2, 3) se39 se38 se37 se36 se35 se34 se33 se32 0000 0000 147,229 19eh lcdse5 (2, 3) ? ? ? ? ? ? se41 se40 ---- --00 147,229 19fh ? unimplemented ? ? legend: ? = unimplemented locations read as ? 0 ?, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: this register is only initialized by a por or bor reset and is unchanged by other resets. 3: pic16f946 only.
pic16f913/914/916/917/946 ds41250f-page 32 ? 2007 microchip technology inc. 2.2.2.1 status register the status register, shown in register 2-1, contains: ? the arithmetic status of the alu ? the reset status ? the bank select bits for data memory (sram) the status register can be the destination for any instruction, like any other register. if the status register is the destination for an instruction that affects the z, dc or c bits, then the write to these three bits is disabled. these bits are set or cleared according to the device logic. furthermore, the to and pd bits are not writable. therefore, the result of an instruction with the status register as destination may be different than intended. for example, clrf status will clear the upper three bits and set the z bit. this leaves the status register as ? 000u u1uu ? (where u = unchanged). it is recommended, therefore, that only bcf, bsf, swapf and movwf instructions are used to alter the status register, because these instructions do not affect any status bits. for other instructions not affecting any status bits (see section 17.0 ?instruction set summary? ). note 1: the c and dc bits operate as b orrow and digit borrow out bits, respectively, in subtraction. register 2-1: status: status register r/w-0 r/w-0 r/w-0 r-1 r-1 r/w-x r/w-x r/w-x irp rp1 rp0 to pd zdc (1) c (1) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 irp: register bank select bit (used for indirect addressing) 1 = bank 2, 3 (100h-1ffh) 0 = bank 0, 1 (00h-ffh) bit 6-5 rp<1:0>: register bank select bits (used for direct addressing) 00 = bank 0 (00h-7fh) 01 = bank 1 (80h-ffh) 10 = bank 2 (100h-17fh) 11 = bank 3 (180h-1ffh) bit 4 to : time-out bit 1 = after power-up, clrwdt instruction or sleep instruction 0 = a wdt time-out occurred bit 3 pd : power-down bit 1 = after power-up or by the clrwdt instruction 0 = by execution of the sleep instruction bit 2 z: zero bit 1 = the result of an arithmetic or logic operation is zero 0 = the result of an arithmetic or logic operation is not zero bit 1 dc: digit carry/borrow bit ( addwf , addlw,sublw,subwf instructions) (1) 1 = a carry-out from the 4th low-order bit of the result occurred 0 = no carry-out from the 4th low-order bit of the result bit 0 c: carry/borrow bit (1) ( addwf , addlw, sublw, subwf instructions) (1) 1 = a carry-out from the most significant bit of the result occurred 0 = no carry-out from the most significant bit of the result occurred note 1: for borrow , the polarity is reversed. a subtraction is executed by adding the two?s complement of the second operand. for rotate ( rrf , rlf ) instructions, this bit is loaded with either the high-order or low-order bit of the source register.
? 2007 microchip technology inc. ds41250f-page 33 pic16f913/914/916/917/946 2.2.2.2 option register the option register, shown in register 2-2, is a readable and writable register, which contains various control bits to configure: ? timer0/wdt prescaler ? external rb0/int interrupt ?timer0 ? weak pull-ups on portb note: to achieve a 1:1 prescaler assignment for timer0, assign the prescaler to the wdt by setting psa bit of the option register to ? 1 ?. see section 6.3 ?timer1 prescaler? . register 2-2: option_reg: option register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r b pu intedg t0cs t0se psa ps2 ps1 ps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 r bp u : portb pull-up enable bit 1 = portb pull-ups are disabled 0 = portb pull-ups are enabled by individual bits in the wpub register bit 6 intedg: interrupt edge select bit 1 = interrupt on rising edge of rb0/int pin 0 = interrupt on falling edge of rb0/int pin bit 5 t0cs: timer0 clock source select bit 1 = transition on ra4/t0cki pin 0 = internal instruction cycle clock (f osc /4) bit 4 t0se: timer0 source edge select bit 1 = increment on high-to-low transition on ra4/t0cki pin 0 = increment on low-to-high transition on ra4/t0cki pin bit 3 psa: prescaler assignment bit 1 = prescaler is assigned to the wdt 0 = prescaler is assigned to the timer0 module bit 2-0 ps<2:0>: prescaler rate select bits 000 001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 1 : 1 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 bit value timer0 rate wdt rate
pic16f913/914/916/917/946 ds41250f-page 34 ? 2007 microchip technology inc. 2.2.2.3 intcon register the intcon register is a readable and writable register, which contains the various enable and flag bits for tmr0 register overflow, portb change and external rb0/int/seg0 pin interrupts. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie of the intcon register. user software should ensure the appropri- ate interrupt flag bits are clear prior to enabling an interrupt. register 2-3: intcon: interrupt control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-x gie peie t0ie inte rbie (1) t0if (2) intf rbif bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 gie: global interrupt enable bit 1 = enables all unmasked interrupts 0 = disables all interrupts bit 6 peie: peripheral interrupt enable bit 1 = enables all unmasked peripheral interrupts 0 = disables all peripheral interrupts bit 5 t0ie: timer0 overflow interrupt enable bit 1 = enables the timer0 interrupt 0 = disables the timer0 interrupt bit 4 inte: rb0/int external interrupt enable bit 1 = enables the rb0/int external interrupt 0 = disables the rb0/int external interrupt bit 3 rbie: portb change interrupt enable bit (1) 1 = enables the portb change interrupt 0 = disables the portb change interrupt bit 2 t0if: timer0 overflow interrupt flag bit (2) 1 = tmr0 register has overflowed (must be cleared in software) 0 = tmr0 register did not overflow bit 1 intf: rb0/int external interrupt flag bit 1 = the rb0/int external interrupt occurred (must be cleared in software) 0 = the rb0/int external interrupt did not occur bit 0 rbif: portb change interrupt flag bit 1 = when at least one of the portb general purpose i/o pins changed state (must be cleared in soft- ware) 0 = none of the portb general purpose i/o pins have changed state note 1: the appropriate bits in the iocb register must also be set. 2: t0if bit is set when timer0 rolls over. timer0 is unchanged on reset and should be initialized before clearing t0if bit.
? 2007 microchip technology inc. ds41250f-page 35 pic16f913/914/916/917/946 2.2.2.4 pie1 register the pie1 register contains the interrupt enable bits, as shown in register 2-4. note: bit peie of the intcon register must be set to enable any peripheral interrupt. register 2-4: pie1: peripheral interrupt enable register 1 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 eeie: ee write complete interrupt enable bit 1 = enables the ee write complete interrupt 0 = disables the ee write complete interrupt bit 6 adie: a/d converter (adc) interrupt enable bit 1 = enables the adc interrupt 0 = disables the adc interrupt bit 5 rcie: usart receive interrupt enable bit 1 = enables the usart receive interrupt 0 = disables the usart receive interrupt bit 4 txie: usart transmit interrupt enable bit 1 = enables the usart transmit interrupt 0 = disables the usart transmit interrupt bit 3 sspie: synchronous serial port (ssp) interrupt enable bit 1 = enables the ssp interrupt 0 = disables the ssp interrupt bit 2 ccp1ie: ccp1 interrupt enable bit 1 = enables the ccp1 interrupt 0 = disables the ccp1 interrupt bit 1 tmr2ie: tmr2 to pr2 match interrupt enable bit 1 = enables the timer2 to pr2 match interrupt 0 = disables the timer2 to pr2 match interrupt bit 0 tmr1ie: timer1 overflow interrupt enable bit 1 = enables the timer1 overflow interrupt 0 = disables the timer1 overflow interrupt
pic16f913/914/916/917/946 ds41250f-page 36 ? 2007 microchip technology inc. 2.2.2.5 pie2 register the pie2 register contains the interrupt enable bits, as shown in register 2-5. note: bit peie of the intcon register must be set to enable any peripheral interrupt. register 2-5: pie2: peripheral interrupt enable register 2 r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 u-0 r/w-0 osfie c2ie c1ie lcdie ?lvdie ?ccp2ie (1) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 osfie: oscillator fail interrupt enable bit 1 = enables oscillator fail interrupt 0 = disables oscillator fail interrupt bit 6 c2ie: comparator c2 interrupt enable bit 1 = enables comparator c2 interrupt 0 = disables comparator c2 interrupt bit 5 c1ie: comparator c1 interrupt enable bit 1 = enables comparator c1 interrupt 0 = disables comparator c1 interrupt bit 4 lcdie: lcd module interrupt enable bit 1 = enables lcd interrupt 0 = disables lcd interrupt bit 3 unimplemented: read as ? 0 ? bit 2 lvdie: low voltage detect interrupt enable bit 1 = enables lvd interrupt 0 = disables lvd interrupt bit 1 unimplemented: read as ? 0 ? bit 0 ccp2ie: ccp2 interrupt enable bit (1) 1 = enables the ccp2 interrupt 0 = disables the ccp2 interrupt note 1: pic16F914/pic16f917/pic16f946 only.
? 2007 microchip technology inc. ds41250f-page 37 pic16f913/914/916/917/946 2.2.2.6 pir1 register the pir1 register contains the interrupt flag bits, as shown in register 2-6. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie of the intcon register. user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. register 2-6: pir1: peripheral interrupt request register 1 r/w-0 r/w-0 r-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 eeif adif rcif txif sspif ccp1if tmr2if tmr1if bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 eeif: ee write operation interrupt flag bit 1 = the write operation completed (must be cleared in software) 0 = the write operation has not completed or has not started bit 6 adif: a/d converter interrupt flag bit 1 = a/d conversion complete (must be cleared in software) 0 = a/d conversion has not completed or has not been started bit 5 rcif: usart receive interrupt flag bit 1 = the usart receive buffer is full (cleared by reading rcreg) 0 = the usart receive buffer is not full bit 4 txif: usart transmit interrupt flag bit 1 = the usart transmit buffer is empty (cleared by writing to txreg) 0 = the usart transmit buffer is full bit 3 sspif: synchronous serial port (ssp) interrupt flag bit 1 = the transmission/reception is complete (must be cleared in software) 0 = waiting to transmit/receive bit 2 ccp1if: ccp1 interrupt flag bit capture mode : 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode : 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode unused in this mode bit 1 tmr2if: timer2 to pr2 interrupt flag bit 1 = a timer2 to pr2 match occurred (must be cleared in software) 0 = no timer2 to pr2 match occurred bit 0 tmr1if: timer1 overflow interrupt flag bit 1 = the tmr1 register overflowed (must be cleared in software) 0 = the tmr1 register did not overflow
pic16f913/914/916/917/946 ds41250f-page 38 ? 2007 microchip technology inc. 2.2.2.7 pir2 register the pir2 register contains the interrupt flag bits, as shown in register 2-7. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie of the intcon register. user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. register 2-7: pir2: peripheral interrupt request register 2 r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 u-0 r/w-0 osfif c2if c1if lcdif ?lvdif ?ccp2if (1) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 osfif: oscillator fail interrupt flag bit 1 = system oscillator failed, clock input has changed to intosc (must be cleared in software) 0 = system clock operating bit 6 c2if: comparator c2 interrupt flag bit 1 = comparator output (c2out bit) has changed (must be cleared in software) 0 = comparator output (c2out bit) has not changed bit 5 c1if: comparator c1 interrupt flag bit 1 = comparator output (c1out bit) has changed (must be cleared in software) 0 = comparator output (c1out bit) has not changed bit 4 lcdif: lcd module interrupt bit 1 = lcd has generated an interrupt 0 = lcd has not generated an interrupt bit 3 unimplemented: read as ? 0 ? bit 2 lvdif: low voltage detect interrupt flag bit 1 = lvd has generated an interrupt 0 = lvd has not generated an interrupt bit 1 unimplemented: read as ? 0 ? bit 0 ccp2if: ccp2 interrupt flag bit (1) capture mode : 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode : 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode : unused in this mode note 1: pic16F914/pic16f917/pic16f946 only.
? 2007 microchip technology inc. ds41250f-page 39 pic16f913/914/916/917/946 2.2.2.8 pcon register the power control (pcon) register contains flag bits (see table 16-2) to differentiate between a: ? power-on reset (por ) ? brown-out reset (bor ) ? watchdog timer reset (wdt) ? external mclr reset the pcon register also controls the software enable of the bor. the pcon register bits are shown in register 2-8. register 2-8: pcon: power control register u-0 u-0 u-0 r/w-1 u-0 u-0 r/w-0 r/w-x ? ? ? sboren ? ?por bor bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-5 unimplemented: read as ? 0 ? bit 4 sboren: software bor enable bit (1) 1 = bor enabled 0 = bor disabled bit 3-2 unimplemented: read as ? 0 ? bit 1 por : power-on reset status bit 1 = no power-on reset occurred 0 = a power-on reset occurred (must be set in software after a power-on reset occurs) bit 0 bor : brown-out reset status bit 1 = no brown-out reset occurred 0 = a brown-out reset occurred (must be set in software after a power-on reset or brown-out reset occurs) note 1: set boren<1:0> = 01 in the configuration word register for this bit to control the bor .
pic16f913/914/916/917/946 ds41250f-page 40 ? 2007 microchip technology inc. 2.3 pcl and pclath the program counter (pc) is 13 bits wide. the low byte comes from the pcl register, which is a readable and writable register. the high byte (pc<12:8>) is not directly readable or writable and comes from pclath. on any reset, the pc is cleared. figure 2-6 shows the two situations for the loading of the pc. the upper example in figure 2-6 shows how the pc is loaded on a write to pcl (pclath<4:0> pch). the lower example in figure 2-6 shows how the pc is loaded during a call or goto instruction (pclath<4:3> pch). figure 2-6: loading of pc in different situations 2.3.1 computed goto a computed goto is accomplished by adding an offset to the program counter ( addwf pcl ). when perform- ing a table read using a computed goto method, care should be exercised if the table location crosses a pcl memory boundary (each 256-byte block). refer to the application note an556, ?implementing a table read? (ds00556). 2.3.2 stack the pic16f91x/946 family has an 8-level x 13-bit wide hardware stack (see figures 2-1 and 2-2). the stack space is not part of either program or data space and the stack pointer is not readable or writable. the pc is pushed onto the stack when a call instruction is executed or an interrupt causes a branch. the stack is poped in the event of a return , retlw or a retfie instruction execution. pclath is not affected by a push or pop operation. the stack operates as a circular buffer. this means that after the stack has been pushed eight times, the ninth push overwrites the value that was stored from the first push. the tenth push overwrites the second push (and so on). 2.4 program memory paging all pic16f91x/946 devices are capable of addressing a continuous 8k word block of program memory. the call and goto instructions provide only 11 bits of address to allow branching within any 2k program memory page. when doing a call or goto instruction, the upper 2 bits of the address are provided by pclath<4:3>. when doing a call or goto instruc- tion, the user must ensure that the page select bits are programmed so that the desired program memory page is addressed. if a return from a call instruction (or interrupt) is executed, the entire 13-bit pc is poped off the stack. therefore, manipulation of the pclath<4:3> bits is not required for the return instructions (which pops the address from the stack). example 2-1 shows the calling of a subroutine in page 1 of the program memory. this example assumes that pclath is saved and restored by the interrupt service routine (if interrupts are used). example 2-1: call of a subroutine in page 1 from page 0 pc 12 8 7 0 5 pclath<4:0> pclath instruction with alu result goto , call opcode<10:0> 8 pc 12 11 10 0 11 pclath<4:3> pch pcl 87 2 pclath pch pcl pcl as destination note 1: there are no status bits to indicate stack overflow or stack underflow conditions. 2: there are no instructions/mnemonics called push or pop. these are actions that occur from the execution of the call , return , retlw and retfie instruc- tions or the vectoring to an interrupt address. note: the contents of the pclath register are unchanged after a return or retfie instruction is executed. the user must rewrite the contents of the pclath regis- ter for any subsequent subroutine calls or goto instructions. org 500h bcf pclath,4 bsf pclath,3 ;select page 1 ;(800h-fffh) call sub1_p1 ;call subroutine in : ;page 1 (800h-fffh) : org 900h ;page 1 (800h-fffh) sub1_p1 : ;called subroutine ;page 1 (800h-fffh) : return ;return to ;call subroutine ;in page 0 ;(000h-7ffh)
? 2007 microchip technology inc. ds41250f-page 41 pic16f913/914/916/917/946 2.5 indirect addressing, indf and fsr registers the indf register is not a physical register. addressing the indf register will cause indirect addressing. indirect addressing is possible by using the indf register. any instruction using the indf register actually accesses data pointed to by the file select register (fsr). reading indf itself indirectly will produce 00h. writing to the indf register indirectly results in a no operation (although status bits may be affected). an effective 9-bit address is obtained by concatenating the 8-bit fsr register and the irp bit of the status register, as shown in figure 2-7. a simple program to clear ram location 020h-02fh using indirect addressing is shown in example 2-2. example 2-2: indirect addressing figure 2-7: direct/indirect addressing pic16f91x/946 movlw 020h ;initialize pointer movwf fsr ;to ram bankisel 020h next clrf indf ;clear indf register incf fsr ;inc pointer btfss fsr,4 ;all done? goto next ;no clear next continue ;yes continue note: for memory map detail, see figures 2-3 and 2-4. data memory indirect addressing direct addressing bank select location select rp1 rp0 6 0 from opcode irp file select register 7 0 bank select location select 00 01 10 11 180h 1ffh 00h 7fh bank 0 bank 1 bank 2 bank 3
pic16f913/914/916/917/946 ds41250f-page 42 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 43 pic16f913/914/916/917/946 3.0 i/o ports the pic16f913/914/916/917/946 family of devices includes several 8-bit port registers along with their corresponding tris registers and one four bit port: ? porta and trisa ? portb and trisb ? portc and trisc ? portd and trisd (1) ? porte and trise ? portf and trisf (2) ? portg and trisg (2) porta, portb, portc and re3/mclr /v pp are implemented on all devices. portd and re<2:0> (porte) are implemented only on the pic16F914/917 and pic16f946. re<7:4> (porte), portf and portg are implemented only on the pic16f946. 3.1 ansel register the ansel register (register 3-1) is used to configure the input mode of an i/o pin to analog. setting the appropriate ansel bit high will cause all digital reads on the pin to be read as ? 0 ? and allow analog functions on the pin to operate correctly. the state of the ansel bits has no affect on digital out- put functions. a pin with tris clear and ansel set will still operate as a digital output, but the input mode will be analog. this can cause unexpected behavior when executing read-modify-write instructions on the affected port. note 1: pic16F914/917 and pic16f946 only. 2: pic16f946 only register 3-1: ansel: analog select register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 ans7 (2) ans6 (2) ans5 (2) ans4 ans3 ans2 ans1 ans0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 ans<7:0> : analog select bits analog select between analog or digital function on pins an<7:0>, respectively. 1 = analog input. pin is assigned as analog input (1) . 0 = digital i/o. pin is assigned to port or special function. note 1: setting a pin to an analog input automatically disables the digital input circuitry, weak pull-ups, and interrupt-on-change if available. the corresponding tris bit must be set to input mode in order to allow external control of the voltage on the pin. 2: pic16F914/pic16f917/pic16f946 only.
pic16f913/914/916/917/946 ds41250f-page 44 ? 2007 microchip technology inc. 3.2 porta and trisa registers porta is a 8-bit wide, bidirectional port. the corresponding data direction register is trisa (register 3-3). setting a trisa bit (= 1 ) will make the corresponding porta pin an input (i.e., put the corresponding output driver in a high-impedance mode). clearing a trisa bit (= 0 ) will make the corresponding porta pin an output (i.e., put the contents of the output latch on the selected pin). example 3-1 shows how to initialize porta. five of the pins of porta can be configured as analog inputs. these pins, ra5 and ra<3:0>, are configured as analog inputs on device power-up and must be reconfigured by the user to be used as i/o?s. this is done by writing the appropriate values to the cmcon0 and ansel registers (see example 3-1). reading the porta register (register 3-2) reads the status of the pins, whereas writing to it will write to the port latch. all write operat ions are read-modify-write operations. therefore, a write to a port means that the port pins are read, this value is modified and then written to the port data latch. the trisa register controls the direction of the porta pins, even when they are being used as analog inputs. the user must ensure the bits in the trisa register are maintained set when using them as analog inputs. i/o pins configured as analog inputs always read ? 0 ?. example 3-1: initializing porta note 1: the cmcon0 and ansel registers must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. banksel porta ; clrf porta ;init porta banksel trisa ; movlw 07h ;set ra<2:0> to movwf cmcon0 ;digital i/o clrf ansel ;make all porta digital i/o movlw 0f0h ;set ra<7:4> as inputs movwf trisa ;and set ra<3:0> as outputs register 3-2: porta: porta register r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 ra<7:0> : porta i/o pin bits 1 = port pin is >v ih min. 0 = port pin is : porta tri-state control bits 1 = porta pin configured as an input (tri-stated) 0 = porta pin configured as an output note 1: trisa<7:6> always reads ? 1 ? in xt, hs and lp oscillator modes.
? 2007 microchip technology inc. ds41250f-page 45 pic16f913/914/916/917/946 3.2.1 pin descriptions and diagrams each porta pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions, refer to the appropriate section in this data sheet. 3.2.1.1 ra0/an0/c1-/seg12 figure 3-1 shows the diagram for this pin. the ra0 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input for the adc ? an analog input for comparator c1 ? an analog output for the lcd figure 3-1: block diagram of ra0 q d q ck data latch tris latch rd trisa rd porta analog input or i/o pin q d q ck ttl input buffer to a/d converter and comparator seg12 se12 and lcden se12 and lcden data bus wr porta wr trisa se12 and lcden v dd v ss
pic16f913/914/916/917/946 ds41250f-page 46 ? 2007 microchip technology inc. 3.2.1.2 ra1/an1/c2-/seg7 figure 3-2 shows the diagram for this pin. the ra1 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input for the adc ? an analog input for comparator c2 ? an analog output for the lcd figure 3-2: blo ck diagram of ra1 q d q ck data latch tris latch rd trisa rd porta q d q ck to a/d converter and comparator seg7 data bus wr porta wr trisa analog input or i/o pin ttl input buffer se7 and lcden se7 and lcden se7 and lcden v dd v ss
? 2007 microchip technology inc. ds41250f-page 47 pic16f913/914/916/917/946 3.2.1.3 ra2/an2/c2+/v ref -/com2 figure 3-3 shows the diagram for this pin. the ra2 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input for the adc ? an analog input for comparator c2 ? a voltage reference input for the adc ? an analog output for the lcd figure 3-3: blo ck diagram of ra2 q d q ck data latch tris latch rd trisa rd porta q d q ck to a/d converter and comparator com2 data bus wr porta wr trisa to a/d module v ref - input analog input or i/o pin ttl input buffer lcden and lmux<1:0> = 1x lcden and lmux<1:0> = 1x lcden and lmux<1:0> = 1x v dd v ss
pic16f913/914/916/917/946 ds41250f-page 48 ? 2007 microchip technology inc. 3.2.1.4 ra3/an3/c1+/v ref +/com3/seg15 figure 3-4 shows the diagram for this pin. the ra3 pin is configurable to function as one of the following: ? a general purpose input ? an analog input for the adc ? an analog input from comparator c1 ? a voltage reference input for the adc ? analog outputs for the lcd figure 3-4: blo ck diagram of ra3 q d q ck data latch tris latch rd trisa rd porta q d q ck ttl input buffer to a/d converter and comparator com3 (1) or seg15 data bus wr porta wr trisa to a / d m o d u l e v ref + input note 1: pic16f913/916 only. 2: for the pic16f913/916, the lcdmode_en = lcden and (se15 or lmux<1:0> = 11 ). for the pic16F914/917 and pic16f946, the lcdmode_en = lcden and se15. q q lcdmode_en (2) analog input or i/o pin lcdmode_en (2) lcdmode_en (2) v dd v ss
? 2007 microchip technology inc. ds41250f-page 49 pic16f913/914/916/917/946 3.2.1.5 ra4/c1out/t0cki/seg4 figure 3-5 shows the diagram for this pin. the ra4 pin is configurable to function as one of the following: ? a general purpose i/o ? a digital output from comparator c1 ? a clock input for timer0 ? an analog output for the lcd figure 3-5: blo ck diagram of ra4 c1out cm<2:0> = 110 or 101 0 1 schmitt trigger q d q ck data latch tris latch rd trisa rd porta q d q ck t0cki data bus wr porta wr trisa seg4 i/o pin ttl input buffer se4 and lcden se4 and lcden se4 and lcden se4 and lcden v dd v ss
pic16f913/914/916/917/946 ds41250f-page 50 ? 2007 microchip technology inc. 3.2.1.6 ra5/an4/c2out/ss /seg5 figure 3-6 shows the diagram for this pin. the ra5 pin is configurable to function as one of the following: ? a general purpose i/o ? a digital output from comparator c2 ? a slave select input ? an analog output for the lcd ? an analog input for the adc figure 3-6: blo ck diagram of ra5 to a/d converter rd trisa rd porta ttl input buffer seg5 se5 and lcden data bus wr porta wr trisa to s s input analog input or se5 and lcden c2out cm<2:0> = 110 or 101 0 1 q d q ck data latch q d q ck i/o pin tris latch se5 and lcden v dd v ss
? 2007 microchip technology inc. ds41250f-page 51 pic16f913/914/916/917/946 3.2.1.7 ra6/osc2/clkout/t1oso figure 3-7 shows the diagram for this pin. the ra6 pin is configurable to function as one of the following: ? a general purpose i/o ? a crystal/resonator connection ? a clock output ? a timer1 oscillator connection figure 3-7: blo ck diagram of ra6 clkout (f osc /4) f osc = 1x1 rd porta ttl input buffer data bus wr porta wr trisa f osc = 00x , 010 f osc = 00x , 010 i/o pin oscillator circuit from osc1 rd trisa 0 1 q d q ck data latch q d q ck tris latch or t1oscen or t1oscen v dd v ss
pic16f913/914/916/917/946 ds41250f-page 52 ? 2007 microchip technology inc. 3.2.1.8 ra7/osc1/clkin/t1osi figure 3-8 shows the diagram for this pin. the ra7 pin is configurable to function as one of the following: ? a general purpose i/o ? a crystal/resonator connection ? a clock input ? a timer1 oscillator connection figure 3-8: blo ck diagram of ra7 table 3-1: summary of registers associated with porta name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets adcon0 adfm vcfg1 vcfg0 chs2 chs1 chs0 go/done adon 0000 0000 0000 0000 ansel ans7 ans6 ans5 ans4 ans3 ans2 ans1 ans0 1111 1111 1111 1111 cmcon0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 0000 0000 config (1) cpd cp mclre pwrte wdte fosc2 fosc1 fosc0 ? ? option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 0000 0000 uuuu uuuu lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 uuuu uuuu porta ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 xxxx xxxx uuuu uuuu sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 uuuu uuuu trisa trisa7 trisa6 trisa5 tri sa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by porta. note 1: see configuration word register (config) for operation of all register bits. q d q ck data latch tris latch rd trisa rd porta q d q ck ttl input buffer data bus wr porta wr trisa f osc = 10x f osc = 10x i/o pin oscillator circuit to os c 2 f osc = 011 v dd v ss
? 2007 microchip technology inc. ds41250f-page 53 pic16f913/914/916/917/946 3.3 portb and trisb registers portb is an 8-bit bidirectional i/o port. all portb pins can have a weak pull-up feature, and portb<7:4> implements an interrupt-on-input change function. portb is also used for the serial flash programming interface and icd interface. example 3-2: initializing portb 3.4 additional portb pin functions rb<7:6> are used as data and clock signals, respectively, for both serial programming and the in-circuit debugger features on the device. also, rb0 can be configured as an external interrupt input. 3.4.1 weak pull-ups each of the portb pins has an individually configurable internal weak pull-up. control bits wpub<7:0> enable or disable each pull-up. refer to register 3-7. each weak pull-up is automatically turned off when the port pin is configured as an output. the pull-ups are disabled on a power-on reset by the rbpu bit of the option register. 3.4.2 interrupt-on-change four of the portb pins are individually configurable as an interrupt-on-change pin. control bits iocb<7:4> enable or disable the interrupt function for each pin. refer to register 3-6. the interrupt-on-change feature is disabled on a power-on reset. for enabled interrupt-on-change pins, the values are compared with the old value latched on the last read of portb. the ?mismatch? outputs of the last read are or?d together to set the portb change interrupt flag bit (rbif) in the intcon register (register 2-3). this interrupt can wake the device from sleep. the user, in the interrupt service routine, clears the interrupt by: a) any read or write of portb. this will end the mismatch condition. b) clear the flag bit rbif. a mismatch condition will continue to set flag bit rbif. reading or writing portb will end the mismatch con- dition and allow flag bit rbif to be cleared. the latch holding the last read value is not affected by a mclr nor brown-out reset. after these resets, the rbif flag will continue to be set if a mismatch is present. banksel portb ; clrf portb ;init portb banksel trisb ; movlw 0ffh ;set rb<7:0> as inputs movwf trisb ; note: if a change on the i/o pin should occur when the read operation is being executed (start of the q2 cycle), then the rbif interrupt flag may not get set. furthermore, since a read or write on a port affects all bits of that port, care must be taken when using multiple pins in interrupt-on-change mode. changes on one pin may not be seen while servicing changes on another pin.
pic16f913/914/916/917/946 ds41250f-page 54 ? 2007 microchip technology inc. register 3-4: port b: portb register r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 rb<7:0> : portb i/o pin bits 1 = port pin is >v ih min. 0 = port pin is : portb tri-state control bits 1 = portb pin configured as an input (tri-stated) 0 = portb pin configured as an output register 3-6: iocb: portb interrupt- on-change register r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 u-0 iocb7 iocb6 iocb5 iocb4 ? ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-4 iocb<7:4>: interrupt-on-change bits 1 = interrupt-on-change enabled 0 = interrupt-on-change disabled bit 3-0 unimplemented: read as ? 0 ?
? 2007 microchip technology inc. ds41250f-page 55 pic16f913/914/916/917/946 register 3-7: wpub: weak pull-up register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 wpub7 wpub6 wpub5 wpub4 wpub3 wpub2 wpub1 wpub0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 wpub<7:0>: weak pull-up register bits 1 = pull-up enabled 0 = pull-up disabled note 1: global rbpu must be enabled for individual pull-ups to be enabled. 2: the weak pull-up device is automatically disabled if the pin is in output mode (trisx<7:0> = 0 ).
pic16f913/914/916/917/946 ds41250f-page 56 ? 2007 microchip technology inc. 3.4.3 pin descriptions and diagrams each portb pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions such as the lcd or interrupts, refer to the appropriate section in this data sheet. 3.4.3.1 rb0/int/seg0 figure 3-9 shows the diagram for this pin. the rb0 pin is configurable to function as one of the following: ? a general purpose i/o ? an external edge triggered interrupt ? an analog output for the lcd 3.4.3.2 rb1/seg1 figure 3-9 shows the diagram for this pin. the rb1 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.4.3.3 rb2/seg2 figure 3-9 shows the diagram for this pin. the rb2 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.4.3.4 rb3/seg3 figure 3-9 shows the diagram for this pin. the rb3 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd figure 3-9: block diagram of rb<3:0> q d ck data latch tris latch rd trisb rd portb q d ck ttl input buffer se<3:0> and lcden data bus wr portb wr trisb p v dd i/o pin weak pull-up se<3:0> seg<3:0> int (1) rbpu note 1: rb0 only. se<3:0> and lcden v dd v ss wpub<3:0> schmitt trigger se0 and lcden
? 2007 microchip technology inc. ds41250f-page 57 pic16f913/914/916/917/946 3.4.3.5 rb4/com0 figure 3-10 shows the diagram for this pin. the rb4 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd figure 3-10: blo ck diagram of rb4 from other set rbif rb<7:4> pins lcden com0 q d ck data latch tris latch rd trisb rd portb q d ck ttl input buffer lcden data bus wr portb wr trisb p v dd i/o pin weak pull-up lcden rbpu d q en lcden q1 q d en rd portb v dd v ss q d ck q rd ioc wr ioc interrupt-on- change write ? 0 ? to rbif q s r wpub<4>
pic16f913/914/916/917/946 ds41250f-page 58 ? 2007 microchip technology inc. 3.4.3.6 rb5/com1 figure 3-11 shows the diagram for this pin. the rb5 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd figure 3-11: block diagram of rb5 from other set rbif rb<7:4> pins lcden and com1 q d ck data latch tris latch rd trisb rd portb q d ck ttl input buffer lcden and lmux<1:0> 00 data bus wr portb wr trisb p v dd i/o pin weak pull-up lcden and lmux<1:0> 00 rbpu d q en lcden and lmux<1:0> 00 rd portb q d en v dd v ss q d ck q rd ioc wr ioc interrupt-on- change write ? 0 ? to rbif q s r lmux<1:0> 00 q1 wpub<5>
? 2007 microchip technology inc. ds41250f-page 59 pic16f913/914/916/917/946 3.4.3.7 rb6/icspclk/icdck/seg14 figure 3-12 shows the diagram for this pin. the rb6 pin is configurable to function as one of the following: ? a general purpose i/o ? an in-circuit serial programming? clock ? an icd clock input ? an analog output for the lcd figure 3-12: blo ck diagram of rb6 from other set rbif rb<7:4> pins q1 program mode/icd icspclk q d ck data latch tris latch rd trisb rd portb q d ck d q en ttl input buffer se14 and lcden data bus wr portb wr trisb p v dd i/o pin weak pull-up se14 and lcden rbpu d q en program mode/icd mode seg14 se14 and lcden v dd v ss q d ck q rd ioc wr ioc interrupt-on- change write ? 0 ? to rbif q s r rd portb wpub<6> schmitt trigger program mode or icd m ode or (se14 and lcden)
pic16f913/914/916/917/946 ds41250f-page 60 ? 2007 microchip technology inc. 3.4.3.8 rb7/icspdat/icddat/seg13 figure 3-13 shows the diagram for this pin. the rb7 pin is configurable to function as one of the following: ? a general purpose i/o ? an in-circuit serial programming? i/o ? an icd data i/o ? an analog output for the lcd figure 3-13: blo ck diagram of rb7 from other set rbif rb<7:4> pins q1 q d ck data latch tris latch q d ck ttl input buffer se13 and lcden data bus wr portb wr trisb p v dd i/o pin weak pull-up se13 and lcden rbpu d q en port /program mode/icd seg13 pgd drven icspdat se13 and lcden program mode/icd v dd v ss rd trisb rd portb q d ck q rd ioc wr ioc rd portb d q en interrupt-on- change write ? 0 ? to rbif q s r 0 1 0 1 icspdat/icddat schmitt trigger program mode or icd mode or (se13 and lcden)
? 2007 microchip technology inc. ds41250f-page 61 pic16f913/914/916/917/946 table 3-2: summary of regist ers associated with portb name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x iocb iocb7 iocb6 iocb5 iocb4 ? ? ? ? 0000 ---- 0000 ---- lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 0000 0000 uuuu uuuu lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 uuuu uuuu option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx xxxx uuuu uuuu trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 1111 1111 1111 wpub wpub7 wpub6 wpub5 wpub4 wpub3 wpub2 wpub1 wpub0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by portb. note 1: this register is only initialized by a por or bor reset and is unchanged by other resets. 2: configuration word register bit debug <12> is also associated with portb. see register 16-1 for more details.
pic16f913/914/916/917/946 ds41250f-page 62 ? 2007 microchip technology inc. 3.5 portc and trisc registers portc is an 8-bit bidirectional port. portc is multiplexed with several peripheral functions. portc pins have schmitt trigger input buffers. all portc pins have latch bits (portc register). they will modify the contents of the portc latch (when written); thus, modifying the value driven out on a pin if the corresponding trisc bit is configured for output. example 3-3: initializing portc banksel portc ; clrf portc ;init portc banksel trisc ; movlw 0ffh ;set rc<7:0> as inputs movwf trisc ; banksel lcdcon ; clrf lcdcon ;disable vlcd<3:1> ;inputs on rc<2:0> register 3-8: port c: portc register r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 rc<7:0> : portc i/o pin bits 1 = port pin is >v ih min. 0 = port pin is : portc tri-state control bits 1 = portc pin configured as an input (tri-stated) 0 = portc pin configured as an output
? 2007 microchip technology inc. ds41250f-page 63 pic16f913/914/916/917/946 3.5.1 pin descriptions and diagrams each portc pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions such as the lcd or ssp, refer to the appropriate section in this data sheet. 3.5.1.1 rc0/vlcd1 figure 3-14 shows the diagram for this pin. the rc0 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input for the lcd bias voltage 3.5.1.2 rc1/vlcd2 figure 3-15 shows the diagram for this pin. the rc1 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input for the lcd bias voltage 3.5.1.3 rc2/vlcd3 figure 3-16 shows the diagram for this pin. the rc2 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input for the lcd bias voltage figure 3-14: blo ck diagram of rc0 rd portc vlcd1 i/o pin schmitt trigger q d ck data latch tris latch rd trisc data bus wr portc wr trisc q d ck q q (vlcden and lmux<1:0> 00 ) (lcden and lmux<1:0> 00) v dd v ss
pic16f913/914/916/917/946 ds41250f-page 64 ? 2007 microchip technology inc. figure 3-15: blo ck diagram of rc1 figure 3-16: blo ck diagram of rc2 rd portc vlcd2 i/o pin schmitt trigger q d ck data latch tris latch rd trisc data bus wr portc wr trisc q d ck q q (lcden and lmux<1:0> 00 ) (vlcden and lmux<1:0> 00 ) v dd v ss rd portc vlcd3 i/o pin schmitt trigger q d ck data latch tris latch rd trisc data bus wr portc wr trisc q d ck q q vlcden lcden v dd v ss
? 2007 microchip technology inc. ds41250f-page 65 pic16f913/914/916/917/946 3.5.1.4 rc3/seg6 figure 3-17 shows the diagram for this pin. the rc3 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd figure 3-17: blo ck diagram of rc3 rd portc seg6 and lcden i/o pin schmitt trigger q d ck data latch tris latch rd trisc data bus wr portc wr trisc q d ck q q se6 and lcden se6 and lcden v dd v ss
pic16f913/914/916/917/946 ds41250f-page 66 ? 2007 microchip technology inc. 3.5.1.5 rc4/t1g /sdo/seg11 figure 3-18 shows the diagram for this pin. the rc4pin is configurable to function as one of the following: ? a general purpose i/o ? a timer1 gate input ? a serial data output ? an analog output for the lcd figure 3-18: block diagram of rc4 sdo port/sdo select rd portc data bus wr portc wr trisc i/o pin rd trisc 1 0 q d q ck data latch q d q ck tris latch schmitt trigger se11 and lcden timer1 gate seg11 se11 and lcden v dd v ss
? 2007 microchip technology inc. ds41250f-page 67 pic16f913/914/916/917/946 3.5.1.6 rc5/t1cki/ccp1/seg10 figure 3-19 shows the diagram for this pin. the rc5 pin is configurable to function as one of the following: ? a general purpose i/o ? a timer1 clock input ? a capture input, compare output or pwm output ? an analog output for the lcd figure 3-19: block diagram of rc5 ccp1 data out (port/ccp1 select) and ccpmx rd portc data bus wr portc wr trisc i/o pin rd trisc 1 0 q d q ck data latch q d q ck tris latch schmitt trigger se10 and lcden timer1 clock input seg10 se10 and lcden v dd v ss
pic16f913/914/916/917/946 ds41250f-page 68 ? 2007 microchip technology inc. 3.5.1.7 rc6/tx/ck/sck/scl/seg9 figure 3-20 shows the diagram for this pin. the rc6 pin is configurable to function as one of the following: ? a general purpose i/o ? an asynchronous serial output ? a synchronous clock i/o ? a spi clock i/o ?an i 2 c data i/o ? an analog output for the lcd figure 3-20: block diagram of rc6 tx/ck data out i 2 c ? data out rd portc data bus wr portc wr trisc i/o pin rd trisc q d q ck data latch q d q ck tris latch schmitt trigger se9 and lcden ck/scl/sck input seg9 se9 and lcden port/usart/ssp mode select (1) usart or i 2 c ? drive note 1: if all three data output sources are enabled, the following priority order will be used: ? usart data (highest) ? ssp data ? port data (lowest) sck data out v dd v ss
? 2007 microchip technology inc. ds41250f-page 69 pic16f913/914/916/917/946 3.5.1.8 rc7/rx/dt/sdi/sda/seg8 figure 3-21 shows the diagram for this pin. the rc7 pin is configurable to function as one of the following: ? a general purpose i/o ? an asynchronous serial input ? a synchronous serial data i/o ? a spi data input ?an i 2 c data i/o ? an analog output for the lcd figure 3-21: block diagram of rc7 data bus wr portc wr trisc rd portc rx/sdi input seg8 0 1 i 2 c ? data out schmitt trigger i/o pin data latch tris latch q d q ck q d q ck i 2 c ? drive se8 and lcden rd trisc port/(usart or i 2 c ? ) select usart/i 2 c ? mode select (1) dt data out or scen drive se8 and lcden note 1: if all three data output sources are enabled, the following priority order will be used: ? usart data (highest) ? ssp data ? port data (lowest) v dd v ss
pic16f913/914/916/917/946 ds41250f-page 70 ? 2007 microchip technology inc. table 3-3: summary of registers associated with portc name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets ccp1con ? ? ccp1x ccp1y ccp1m3 ccp1m2 ccp1m1 ccp1m0 --00 0000 --00 0000 lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 0000 0000 uuuu uuuu lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 uuuu uuuu portc rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 xxxx xxxx uuuu uuuu rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 uuuu uuuu trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by portc.
? 2007 microchip technology inc. ds41250f-page 71 pic16f913/914/916/917/946 3.6 portd and trisd registers portd is an 8-bit port with schmitt trigger input buffers. each pin is individually configured as an input or output. portd is only available on the pic16F914/917 and pic16f946. example 3-4: initializing portd banksel portd ; clrf portd ;init portd banksel trisd ; movlw 0ff ;set rd<7:0> as inputs movwf trisd ; register 3-10: port d: portd register r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x rd7 rd6 rd5 rd4 rd3 rd2 rd1 rd0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 rd<7:0> : portd i/o pin bits 1 = port pin is >v ih min. 0 = port pin is : portd tri-state control bits 1 = portd pin configured as an input (tri-stated) 0 = portd pin configured as an output
pic16f913/914/916/917/946 ds41250f-page 72 ? 2007 microchip technology inc. 3.6.1 pin descriptions and diagrams each portd pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions such as the comparator or the adc, refer to the appropriate section in this data sheet. 3.6.1.1 rd0/com3 figure 3-22 shows the diagram for this pin. the rd0 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.6.1.2 rd1 figure 3-23 shows the diagram for this pin. the rd1 pin is configurable to function as one of the following: ? a general purpose i/o 3.6.1.3 rd2/ccp2 figure 3-24 shows the diagram for this pin. the rd2 pin is configurable to function as one of the following: ? a general purpose i/o ? a capture input, compare output or pwm output 3.6.1.4 rd3/seg16 figure 3-25 shows the diagram for this pin. the rd3 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.6.1.5 rd4/seg17 figure 3-25 shows the diagram for this pin. the rd4 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.6.1.6 rd5/seg18 figure 3-25 shows the diagram for this pin. the rd5 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.6.1.7 rd6/seg19 figure 3-25 shows the diagram for this pin. the rd6 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.6.1.8 rd7/seg20 figure 3-25 shows the diagram for this pin. the rd7 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd
? 2007 microchip technology inc. ds41250f-page 73 pic16f913/914/916/917/946 figure 3-22: block diagram of rd0 figure 3-23: block di agram of rd1 data bus wr portd wr trisd rd portd com3 schmitt trigger i/o pin data latch tris latch q d q ck q d q ck lcden and lmux<1:0> = 11 rd trisd lcden and lmux<1:0> = 11 v dd v ss data bus wr portd wr trisd rd portd rd1 pin data latch tris latch q d q ck q d q ck rd trisd v dd v ss schmitt trigger
pic16f913/914/916/917/946 ds41250f-page 74 ? 2007 microchip technology inc. figure 3-24: block diagram of rd2 figure 3-25: block diag ram of rd<7:3> data bus wr portd wr trisd rd portd ccp2 input 0 1 (port/ccp2 select) and ccpmx ccp2 data out i/o pin data latch tris latch q d q ck q d q ck rd trisd v dd v ss schmitt trigger data bus wr portd wr trisd rd portd seg<20:16> i/o pin data latch tris latch q d q ck q d q ck se<20:16> and lcden rd trisd schmitt trigger se<20:16> and lcden v dd v ss
? 2007 microchip technology inc. ds41250f-page 75 pic16f913/914/916/917/946 table 3-4: summary of regist ers associated with portd (1) name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets ccp2con (1) ? ? ccp2x ccp2y ccp2m3 ccp2m2 ccp2m1 ccp2m0 --00 0000 --00 0000 lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse2 (1) se23 se22 se21 se20 se19 se18 se17 se16 0000 0000 uuuu uuuu portd (1) rd7 rd6 rd5 rd4 rd3 rd2 rd1 rd0 xxxx xxxx uuuu uuuu trisd (1) trisd7 trisd6 trisd5 trisd4 trisd3 trisd2 trisd1 trisd0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by portd. note 1: pic16F914/917 and pic16f946 only.
pic16f913/914/916/917/946 ds41250f-page 76 ? 2007 microchip technology inc. 3.7 porte and trise registers porte is a 1-bit, 4-bit or 8-bit port with schmitt trigger input buffers. re<7:4, 2:0> are individually configured as inputs or outputs and re3 is only available as an input if mclre is ? 0 ? in configuration word (register 16-1). re<2:0> are only available on the pic16F914/917 and pic16f946. re<7:4> are only available on the pic16f946. example 3-5: initializing porte banksel porte ; clrf porte ;init porte banksel trise ; movlw 0fh ;set re<3:0> as inputs movwf trise ; clrf ansel ;make re<2:0> as i/o?s register 3-12: port e: porte register r/w-x r/w-x r/w-x r/w-x r-x r/w-x r/w-x r/w-x re7 (1,3) re6 (1,3) re5 (1,3) re4 (1,3) re3 re2 (2,4) re1 (2,4) re0 (2,4) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 re<7:0> : porte i/o pin bits 1 = port pin is >v ih min. 0 = port pin is 16F914/917 and pic16f946 only. 3: pic16f91x, read as ? 0 ?. 4: pic16f913/916, read as ? 0 ?. register 3-13: trise: porte tri-state register r/w-1 r/w-1 r/w-1 r/w-1 r-1 r/w-1 r/w-1 r/w-1 trise7 (1,3) trise6 (1,3) trise5 (1,3) trise4 (1,3) trise3 trise2 (2,4) trise1 (2,4) trise0 (2,4) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 trise<7:0>: porte tri-state control bits 1 = porte pin configured as an input (tri-stated) 0 = porte pin configured as an output note 1: pic16f946 only. 2: pic16F914/917 and pic16f946 only. 3: pic16f91x, read as ? 0 ?. 4: pic16f913/916, read as ? 0 ?.
? 2007 microchip technology inc. ds41250f-page 77 pic16f913/914/916/917/946 3.7.1 pin descriptions and diagrams each porte pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions such as the comparator or the adc, refer to the appropriate section in this data sheet. 3.7.1.1 re0/an5/seg21 (1) figure 3-26 shows the diagram for this pin. the re0 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input for the adc ? an analog output for the lcd 3.7.1.2 re1/an6/seg22 (1) figure 3-26 shows the diagram for this pin. the re1 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input for the adc ? an analog output for the lcd 3.7.1.3 re2/an7/seg23 (1) figure 3-26 shows the diagram for this pin. the re2 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog input for the adc ? an analog output for the lcd 3.7.1.4 re3/mclr /v pp figure 3-27 shows the diagram for this pin. the re3 pin is configurable to function as one of the following: ? a digital input only ? as master clear reset with weak pull-up ? a programming voltage reference input 3.7.1.5 re4/seg24 (2) figure 3-28 shows the diagram for this pin. the re4/seg24 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.7.1.6 re5/seg25 (2) figure 3-28 shows the diagram for this pin. the re5/seg25 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.7.1.7 re6/seg26 (2) figure 3-28 shows the diagram for this pin. the re6/seg26 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.7.1.8 re7/seg27 (2) figure 3-28 shows the diagram for this pin. the re7/seg27 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd note 1: pin is available on the pic16F914/917 and pic16f946 only. 2: pin is available on the pic16f946 only.
pic16f913/914/916/917/946 ds41250f-page 78 ? 2007 microchip technology inc. figure 3-26: block diagram of re<2:0> (pic16F914/917 and pic16f946 only) figure 3-27: block diagram of re3 data bus wr porte wr trise rd porte seg<23:21> schmitt trigger i/o pin data latch tris latch q d q ck q d q ck analog mode or rd trise an<7:5> seg<23:21> and lcden seg<23:21> and lcden v dd v ss and lcden hv detect mclr filter input pin rd porte mclr circuit programming mode data bus rd trise m clre hv buffer schmitt trigger hv buffer schmitt trigger v ss v ss
? 2007 microchip technology inc. ds41250f-page 79 pic16f913/914/916/917/946 figure 3-28: block diagram of re<7:4> (pic16f946 only) data bus wr porte wr trise rd porte seg<27:24> schmitt trigger i/o pin data latch tris latch q d q ck q d q ck analog mode or rd trise an<7:5> seg<27:24> and lcden seg<27:24> and lcden v dd v ss
pic16f913/914/916/917/946 ds41250f-page 80 ? 2007 microchip technology inc. table 3-5: summary of registers associated with porte name bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets adcon0 adfm vcfg1 vcfg0 chs2 chs1 chs0 go/done adon 0000 0000 0000 0000 ansel ans7 ans6 ans5 ans4 ans3 ans2 ans1 ans0 1111 1111 1111 1111 lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse2 (1,2) se23 se22 se21 se20 se19 se18 se17 se16 0000 0000 uuuu uuuu lcdse3 (1, 3) se31 se30 se29 se28 se27 se26 se25 se24 0000 0000 uuuu uuuu porte re7 (3) re6 (3) re5 (3) re4 (3) re3 re2 (2) re1 (2) re0 (2) xxxx xxxx uuuu uuuu trise trise7 (3) trise6 (3) trise5 (3) trise4 (3) trise3 (4) trise2 (2) trise1 (2) trise0 (2) 1111 1111 1111 1111 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by portc. note 1: this register is only initialized by a por or bor reset and is unchanged by other resets. 2: pic16F914/917 and pic16f946 only. 3: pic16f946 only. 4: bit is read-only; trise = 1 always.
? 2007 microchip technology inc. ds41250f-page 81 pic16f913/914/916/917/946 3.8 portf and trisf registers portf is an 8-bit port with schmitt trigger input buff- ers. rf<7:0> are individually configured as inputs or outputs, depending on the state of the port direction. the port bits are also multiplexed with lcd segment functions. portf is available on the pic16f946 only. example 3-6: initializing portf banksel portf ; clrf portf ;init portf banksel trisf ; movlw 0ffh ;set rf<7:0> as inputs movwf trisf ; register 3-14: portf: portf register (1) r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x rf7 rf6 rf5 rf4 rf3 rf2 rf1 rf0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 rf<7:0> : portf i/o pin bits 1 = port pin is >v ih min. 0 = port pin is : portf tri-state control bits 1 = portf pin configured as an input (tri-stated) 0 = portf pin configured as an output note 1: pic16f946 only.
pic16f913/914/916/917/946 ds41250f-page 82 ? 2007 microchip technology inc. 3.8.1 pin descriptions and diagrams each portf pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions, refer to the appropriate section in this data sheet. 3.8.1.1 rf0/seg32 figure 3-29 shows the diagram for this pin. the rf0 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.8.1.2 rf1/seg33 figure 3-29 shows the diagram for this pin. the rf1 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.8.1.3 rf2/seg34 figure 3-29 shows the diagram for this pin. the rf2 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.8.1.4 rf3/seg35 figure 3-29 shows the diagram for this pin. the rf3 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.8.1.5 rf4/seg28 figure 3-29 shows the diagram for this pin. the rf4 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.8.1.6 rf5/seg29 figure 3-29 shows the diagram for this pin. the rf5 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.8.1.7 rf6/seg30 figure 3-29 shows the diagram for this pin. the rf6 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.8.1.8 rf7/seg31 figure 3-29 shows the diagram for this pin. the rf7 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd
? 2007 microchip technology inc. ds41250f-page 83 pic16f913/914/916/917/946 figure 3-29: block di agram of rf<7:0> table 3-6: summary of regist ers associated with portf (1) name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse3 (1) se31 se30 se29 se28 se27 se26 se25 se24 0000 0000 uuuu uuuu lcdse4 (1) se39 se38 se37 se36 se35 se34 se33 se32 0000 0000 uuuu uuuu portf (1) rf7 rf6 rf5 rf4 rf3 rf2 rf1 rf0 xxxx xxxx uuuu uuuu trisf (1) trisf7 trisf6 trisf5 trisf4 trisf3 trisf2 trisf1 trisf0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by portf. note 1: pic16f946 only. data bus wr portf wr trisf rd portf seg<35:28> schmitt trigger i/o pin data latch tris latch q d q ck q d q ck rd trisf se<35:28> and lcden se<35:28> and lcden v dd v ss
pic16f913/914/916/917/946 ds41250f-page 84 ? 2007 microchip technology inc. 3.9 portg and trisg registers portg is an 8-bit port with schmitt trigger input buffers. rg<5:0> are individually configured as inputs or outputs, depending on the state of the port direction. the port bits are also multiplexed with lcd segment functions. portg is available on the pic16f946 only. example 3-7: initializing portg banksel portg ; clrf portg ;init portg banksel trisg ; movlw 3fh ;set rg<5:0> as inputs movwf trisg ; register 3-16: port g: portg register (1) u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x ? ? rg5 rg4 rg3 rg2 rg1 rg0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5-0 rg<5:0> : portg i/o pin bits 1 = port pin is >v ih min. 0 = port pin is : portg tri-state control bits 1 = portg pin configured as an input (tri-stated) 0 = portg pin configured as an output note 1: pic16f946 only.
? 2007 microchip technology inc. ds41250f-page 85 pic16f913/914/916/917/946 3.9.1 pin descriptions and diagrams each portg pin is multiplexed with other functions. the pins and their combined functions are briefly described here. for specific information about individual functions, refer to the appropriate section in this data sheet. 3.9.1.1 rg0/seg36 figure 3-30 shows the diagram for this pin. the rg0 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.9.1.2 rg1/seg37 figure 3-30 shows the diagram for this pin. the rg1 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.9.1.3 rg2/seg38 figure 3-30 shows the diagram for this pin. the rg2 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.9.1.4 rg3/seg39 figure 3-30 shows the diagram for this pin. the rg3 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.9.1.5 rg4/seg40 figure 3-30 shows the diagram for this pin. the rg4 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd 3.9.1.6 rg5/seg41 figure 3-30 shows the diagram for this pin. the rg5 pin is configurable to function as one of the following: ? a general purpose i/o ? an analog output for the lcd figure 3-30: block di agram of rg<5:0> data bus wr portg wr trisg rd portg seg<41:36> schmitt trigger i/o pin data latch tris latch q d q ck q d q ck rd trisg se<41:36> and lcden se<41:36> and lcden v dd v ss
pic16f913/914/916/917/946 ds41250f-page 86 ? 2007 microchip technology inc. table 3-7: summary of registers associated with portg (1) name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse4 (1) se39 se38 se37 se36 se35 se34 se33 se32 0000 0000 uuuu uuuu lcdse5 (1) ? ? ? ? ? ? se41 se40 ---- --00 ---- --uu portg (1) ? ? rg5 rg4 rg3 rg2 rg1 rg0 --xx xxxx --uu uuuu trisg (1) ? ? trisg5 trisg4 trisg3 trisg2 trisg1 trisg0 --11 1111 --11 1111 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by portg. note 1: pic16f946 only.
? 2007 microchip technology inc. ds41250f-page 87 pic16f913/914/916/917/946 4.0 oscillator module (with fail-safe clock monitor) 4.1 overview the oscillator module has a wide variety of clock sources and selection features that allow it to be used in a wide range of applications while maximizing perfor- mance and minimizing power consumption. figure 4-1 illustrates a block diagram of the oscillator module. clock sources can be configured from external oscillators, quartz crystal resonators, ceramic resonators and resistor-capacitor (rc) circuits. in addition, the system clock source can be configured from one of two internal oscillators, with a choice of speeds selectable via software. additional clock features include: ? selectable system clock source between external or internal via software. ? two-speed start-up mode, which minimizes latency between external oscillator start-up and code execution. ? fail-safe clock monitor (fscm) designed to detect a failure of the external clock source (lp, xt, hs, ec or rc modes) and switch automatically to the internal oscillator. the oscillator module can be configured in one of eight clock modes. 1. ec ? external clock with i/o on osc2/clkout. 2. lp ? 32 khz low-power crystal mode. 3. xt ? medium gain crystal or ceramic resonator oscillator mode. 4. hs ? high gain crystal or ceramic resonator mode. 5. rc ? external resistor-capacitor (rc) with f osc /4 output on osc2/clkout. 6. rcio ? external resistor-capacitor (rc) with i/o on osc2/clkout. 7. intosc ? internal oscillator with f osc /4 output on osc2 and i/o on osc1/clkin. 8. intoscio ? internal oscillator with i/o on osc1/clkin and osc2/clkout. clock source modes are configured by the fosc<2:0> bits in the configuration word register (config). the internal clock can be generated from two internal oscillators. the hfintosc is a calibrated high-frequency oscillator. the lfintosc is an uncalibrated low-frequency oscillator. figure 4-1: simplified pic ? mcu clock source block diagram (cpu and peripherals) osc1 osc2 sleep external oscillator lp, xt, hs, rc, rcio, ec system clock postscaler mux mux 8 mhz 4 mhz 2 mhz 1 mhz 500 khz 125 khz 250 khz ircf<2:0> 111 110 101 100 011 010 001 000 31 khz power-up timer (pwrt) fosc<2:0> (configuration word register) scs<0> (osccon register) internal oscillator (osccon register) watchdog timer (wdt) fail-safe clock monitor (fscm) hfintosc 8 mhz lfintosc 31 khz intosc
pic16f913/914/916/917/946 ds41250f-page 88 ? 2007 microchip technology inc. 4.2 oscillator control the oscillator control (osccon) register (figure 4-1) controls the system clock and frequency selection options. the osccon register contains the following bits: ? frequency selection bits (ircf) ? frequency status bits (hts, lts) ? system clock control bits (osts, scs) register 4-1: osccon: os cillator control register u-0 r/w-1 r/w-1 r/w-0 r-1 r-0 r-0 r/w-0 ? ircf2 ircf1 ircf0 osts (1) hts lts scs bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 unimplemented: read as ? 0 ? bit 6-4 ircf<2:0>: internal oscillator frequency select bits 111 =8mhz 110 = 4 mhz (default) 101 =2mhz 100 =1mhz 011 =500khz 010 =250khz 001 =125khz 000 = 31 khz (lfintosc) bit 3 osts: oscillator start-up time-out status bit (1) 1 = device is running from the clock defined by fosc<2:0> of the configuration word 0 = device is running from the internal oscillator (hfintosc or lfintosc) bit 2 hts: hfintosc status bit (high frequency ? 8 mhz to 125 khz) 1 = hfintosc is stable 0 = hfintosc is not stable bit 1 lts: lfintosc stable bit (low frequency ? 31 khz) 1 = lfintosc is stable 0 = lfintosc is not stable bit 0 scs: system clock select bit 1 = internal oscillator is used for system clock 0 = clock source defined by fosc<2:0> of the configuration word note 1: bit resets to ? 0 ? with two-speed start-up and lp, xt or hs selected as the oscillator mode or fail-safe mode is enabled.
? 2007 microchip technology inc. ds41250f-page 89 pic16f913/914/916/917/946 4.3 clock source modes clock source modes can be classified as external or internal. ? external clock modes rely on external circuitry for the clock source. examples are: oscillator mod- ules (ec mode), quartz crystal resonators or ceramic resonators (lp, xt and hs modes) and resistor-capacitor (rc) mode circuits. ? internal clock sources are contained internally within the oscillator module. the oscillator module has two internal oscillators: the 8 mhz high-frequency internal oscillator (hfintosc) and the 31 khz low-frequency internal oscillator (lfintosc). the system clock can be selected between external or internal clock sources via the system clock select (scs) bit of the osccon register. see section 4.6 ?clock switching? for additional information. 4.4 external clock modes 4.4.1 oscillator start-up timer (ost) if the oscillator module is configured for lp, xt or hs modes, the oscillator start-up timer (ost) counts 1024 oscillations from osc1. this occurs following a power-on reset (por) and when the power-up timer (pwrt) has expired (if configured), or a wake-up from sleep. during this time, the program counter does not increment and program execution is suspended. the ost ensures that the oscillator circuit, using a quartz crystal resonator or ceramic resonator, has started and is providing a stable system clock to the oscillator module. when switching between clock sources, a delay is required to allow the new clock to stabilize. these oscillator delays are shown in table 4-1. in order to minimize latency between external oscillator start-up and code execution, the two-speed clock start-up mode can be selected (see section 4.7 ?two-speed clock start-up mode? ). table 4-1: oscillator delay examples 4.4.2 ec mode the external clock (ec) mode allows an externally generated logic level as the system clock source. when operating in this mode, an external clock source is connected to the osc1 input and the osc2 is available for general purpose i/o. figure 4-2 shows the pin connections for ec mode. the oscillator start-up timer (ost) is disabled when ec mode is selected. therefore, there is no delay in operation after a power-on reset (por) or wake-up from sleep. because the pic ? mcu design is fully static, stopping the external clock input will have the effect of halting the device while leaving all data intact. upon restarting the external clock, the device will resume operation as if no time had elapsed. figure 4-2: external clock (ec) mode operation switch from switch to frequency oscillator delay sleep/por lfintosc hfintosc 31 khz 125 khz to 8 mhz oscillator warm-up delay (t warm ) sleep/por ec, rc dc ? 20 mhz 2 instruction cycles lfintosc (31 khz) ec, rc dc ? 20 mhz 1 cycle of each sleep/por lp, xt, hs 32 khz to 20 mhz 1024 clock cycles (ost) lfintosc (31 khz) hfintosc 125 khz to 8 mhz 1 s (approx.) osc1/clkin osc2/clkout (1) i/o clock from ext. system pic ? mcu note 1: alternate pin functions are listed in section 1.0 ?device overview? .
pic16f913/914/916/917/946 ds41250f-page 90 ? 2007 microchip technology inc. 4.4.3 lp, xt, hs modes the lp, xt and hs modes support the use of quartz crystal resonators or ceramic resonators connected to osc1 and osc2 (figure 4-3). the mode selects a low, medium or high gain setting of the internal inverter-amplifier to support various resonator types and speed. lp oscillator mode selects the lowest gain setting of the internal inverter-amplifier. lp mode current consumption is the least of the three modes. this mode is designed to drive only 32.768 khz tuning-fork type crystals (watch crystals). xt oscillator mode selects the intermediate gain setting of the internal inverter-amplifier. xt mode current consumption is the medium of the three modes. this mode is best suited to drive resonators with a medium drive level specification. hs oscillator mode selects the highest gain setting of the internal inverter-amplifier. hs mode current consumption is the highest of the three modes. this mode is best suited for resonators that require a high drive setting. figure 4-3 and figure 4-4 show typical circuits for quartz crystal and ceramic resonators, respectively. figure 4-3: quartz crystal operation (lp, xt or hs mode) figure 4-4: ceramic resonator operation (xt or hs mode) note 1: a series resistor (r s ) may be required for quartz crystals with low drive level. 2: the value of r f varies with the oscillator mode selected (typically between 2 m to 10 m ) . c1 c2 quartz r s (1) osc1/clkin r f (2) sleep to internal logic pic ? mcu crystal osc2/clkout note 1: quartz crystal characteristics vary according to type, package and manufacturer. the user should consult the manufacturer data sheets for specifications and recommended application. 2: always verify oscillator performance over the v dd and temperature range that is expected for the application. 3: for oscillator design assistance, reference the following microchip applications notes: ? an826, ? crystal oscillator basics and crystal selection for rfpic ? and pic ? devices ? (ds00826) ? an849, ? basic pic ? oscillator design ? (ds00849) ? an943, ? practical pic ? oscillator analysis and design ? (ds00943) ? an949, ? making your oscillator work ? (ds00949) note 1: a series resistor (r s ) may be required for ceramic resonators with low drive level. 2: the value of r f varies with the oscillator mode selected (typically between 2 m to 10 m ) . 3: an additional parallel feedback resistor (r p ) may be required for proper ceramic resonator operation. c1 c2 ceramic r s (1) osc1/clkin r f (2) sleep to internal logic pic ? mcu r p (3) resonator osc2/clkout
? 2007 microchip technology inc. ds41250f-page 91 pic16f913/914/916/917/946 4.4.4 external rc modes the external resistor-capacitor (rc) modes support the use of an external rc circuit. this allows the designer maximum flexibility in frequency choice while keeping costs to a minimum when clock accuracy is not required. there are two modes: rc and rcio. in rc mode, the rc circuit connects to osc1. osc2/clkout outputs the rc oscillator frequency divided by 4. this signal may be used to provide a clock for external circuitry, synchronization, calibration, test or other application requirements. figure 4-5 shows the external rc mode connections. figure 4-5: external rc modes in rcio mode, the rc circuit is connected to osc1. osc2 becomes an additional general purpose i/o pin. the rc oscillator frequency is a function of the supply voltage, the resistor (r ext ) and capacitor (c ext ) values and the operating temperature. other factors affecting the oscillator frequency are: ? threshold voltage variation ? component tolerances ? packaging variations in capacitance the user also needs to take into account variation due to tolerance of external rc components used. 4.5 internal clock modes the oscillator module has two independent, internal oscillators that can be configured or selected as the system clock source. 1. the hfintosc (high-frequency internal oscillator) is factory calibrated and operates at 8 mhz. the frequency of the hfintosc can be user-adjusted via software using the osctune register (register 4-2). 2. the lfintosc (low-frequency internal oscillator) is uncalibrated and operates at 31 khz. the system clock speed can be selected via software using the internal oscillator frequency select bits ircf<2:0> of the osccon register. the system clock can be selected between external or internal clock sources via the system clock selection (scs) bit of the osccon register. see section 4.6 ?clock switching? for more information. 4.5.1 intosc and intoscio modes the intosc and intoscio modes configure the internal oscillators as the system clock source when the device is programmed using the oscillator selection or the fosc<2:0> bits in the configuration word register (config). see section 16.0 ?special features of the cpu? for more information. in intosc mode, osc1/clkin is available for general purpose i/o. osc2/clkout outputs the selected internal oscillator frequency divided by 4. the clkout signal may be used to provide a clock for external circuitry, synchronization, calibration, test or other application requirements. in intoscio mode, osc1/clkin and osc2/clkout are available for general purpose i/o. 4.5.2 hfintosc the high-frequency internal oscillator (hfintosc) is a factory calibrated 8 mhz internal clock source. the frequency of the hfintosc can be altered via software using the osctune register (register 4-2). the output of the hfintosc connects to a postscaler and multiplexer (see figure 4-1). one of seven frequencies can be selected via software using the ircf<2:0> bits of the osccon register. see section 4.5.4 ?frequency select bits (ircf)? for more information. the hfintosc is enabled by selecting any frequency between 8 mhz and 125 khz by setting the ircf<2:0> bits of the osccon register 000 . then, set the system clock source (scs) bit of the osccon register to ? 1 ? or enable two-speed start-up by setting the ieso bit in the configuration word register (config) to ? 1 ?. the hf internal oscillator (hts) bit of the osccon register indicates whether the hfintosc is stable or not. osc2/clkout (1) c ext r ext pic ? mcu osc1/clkin f osc /4 or internal clock v dd v ss recommended values: 10 k r ext 100 k , <3v 3 k r ext 100 k , 3-5v c ext > 20 pf, 2-5v note 1: alternate pin functions are listed in section 1.0 ?device overview? . 2: output depends upon rc or rcio clock mode. i/o (2)
pic16f913/914/916/917/946 ds41250f-page 92 ? 2007 microchip technology inc. 4.5.2.1 osctune register the hfintosc is factory calibrated but can be adjusted in software by writing to the osctune register (register 4-2). the default value of the osctune register is ? 0 ?. the value is a 5-bit two?s complement number. when the osctune register is modified, the hfintosc frequency will begin shifting to the new frequency. code execution continues during this shift. there is no indication that the shift has occurred. osctune does not affect the lfintosc frequency. operation of features that depend on the lfintosc clock source frequency, such as the power-up timer (pwrt), watchdog timer (wdt), fail-safe clock monitor (fscm) and peripherals, are not affected by the change in frequency. register 4-2: osctune: osci llator tuning register u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? ? tun4 tun3 tun2 tun1 tun0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-5 unimplemented: read as ? 0 ? bit 4-0 tun<4:0>: frequency tuning bits 01111 = maximum frequency 01110 = ? ? ? 00001 = 00000 = oscillator module is running at the factory-calibrated frequency. 11111 = ? ? ? 10000 = minimum frequency
? 2007 microchip technology inc. ds41250f-page 93 pic16f913/914/916/917/946 4.5.3 lfintosc the low-frequency internal oscillator (lfintosc) is an uncalibrated 31 khz internal clock source. the output of the lfintosc connects to a postscaler and multiplexer (see figure 4-1). select 31 khz, via software, using the ircf<2:0> bits of the osccon register. see section 4.5.4 ?frequency select bits (ircf)? for more information. the lfintosc is also the frequency for the power-up timer (pwrt), watchdog timer (wdt) and fail-safe clock monitor (fscm). the lfintosc is enabled by selecting 31 khz (ircf<2:0> bits of the osccon register = 000) as the system clock source (scs bit of the osccon register = 1 ), or when any of the following are enabled: ? two-speed start-up ieso bit of the configuration word register = 1 and ircf<2:0> bits of the osccon register = 000 ? power-up timer (pwrt) ? watchdog timer (wdt) ? fail-safe clock monitor (fscm) the lf internal oscillator (lts) bit of the osccon register indicates whether the lfintosc is stable or not. 4.5.4 frequency select bits (ircf) the output of the 8 mhz hfintosc and 31 khz lfintosc connects to a postscaler and multiplexer (see figure 4-1). the internal oscillator frequency select bits ircf<2:0> of the osccon register select the frequency output of the internal oscillators. one of eight frequencies can be selected via software: ?8 mhz ? 4 mhz (default after reset) ?2 mhz ?1 mhz ? 500 khz ? 250 khz ? 125 khz ? 31 khz (lfintosc) 4.5.5 hf and lf intosc clock switch timing when switching between the lfintosc and the hfintosc, the new oscillator may already be shut down to save power (see figure 4-6). if this is the case, there is a delay after the ircf<2:0> bits of the osccon register are modified before the frequency selection takes place. the lts and hts bits of the osccon register will reflect the current active status of the lfintosc and hfintosc oscillators. the timing of a frequency selection is as follows: 1. ircf<2:0> bits of the osccon register are modified. 2. if the new clock is shut down, a clock start-up delay is started. 3. clock switch circuitry waits for a falling edge of the current clock. 4. clkout is held low and the clock switch circuitry waits for a rising edge in the new clock. 5. clkout is now connected with the new clock. lts and hts bits of the osccon register are updated as required. 6. clock switch is complete. see figure 4-1 for more details. if the internal oscillator speed selected is between 8 mhz and 125 khz, there is no start-up delay before the new frequency is selected. this is because the old and new frequencies are derived from the hfintosc via the postscaler and multiplexer. start-up delay specifications are located under the oscillator parameters of section 19.0 ?electrical specifications? . note: following any reset, the ircf<2:0> bits of the osccon register are set to ? 110 ? and the frequency selection is set to 4 mhz. the user can modify the ircf bits to select a different frequency.
pic16f913/914/916/917/946 ds41250f-page 94 ? 2007 microchip technology inc. figure 4-6: internal oscillator switch timing hfintosc lfintosc ircf <2:0> system clock hfintosc lfintosc ircf <2:0> system clock 0 = 0 0 = 0 start-up time 2-cycle sync running 2-cycle sync running hfintosc lfintosc (fscm and wdt disabled) hfintosc lfintosc (either fscm or wdt enabled) lfintosc hfintosc ircf <2:0> system clock = 0 0 start-up time 2-cycle sync running lfintosc hfintosc lfintosc turns off unless wdt or fscm is enabled
? 2007 microchip technology inc. ds41250f-page 95 pic16f913/914/916/917/946 4.6 clock switching the system clock source can be switched between external and internal clock sources via software using the system clock select (scs) bit of the osccon register. 4.6.1 system clock select (scs) bit the system clock select (scs) bit of the osccon register selects the system clock source that is used for the cpu and peripherals. ? when the scs bit of the osccon register = 0 , the system clock source is determined by configuration of the fosc<2:0> bits in the configuration word register (config). ? when the scs bit of the osccon register = 1 , the system clock source is chosen by the internal oscillator frequency selected by the ircf<2:0> bits of the osccon register. after a reset, the scs bit of the osccon register is always cleared. 4.6.2 oscillator start-up time-out status (osts) bit the oscillator start-up time-out status (osts) bit of the osccon register indicates whether the system clock is running from the external clock source, as defined by the fosc<2:0> bits in the configuration word register (config), or from the internal clock source. in particular, osts indicates that the oscillator start-up timer (ost) has timed out for lp, xt or hs modes. 4.7 two-speed clock start-up mode two-speed start-up mode provides additional power savings by minimizing the latency between external oscillator start-up and code execution. in applications that make heavy use of the sleep mode, two-speed start-up will remove the external oscillator start-up time from the time spent awake and can reduce the overall power consumption of the device. this mode allows the application to wake-up from sleep, perform a few instructions using the intosc as the clock source and go back to sleep without waiting for the primary oscillator to become stable. when the oscillator module is configured for lp, xt or hs modes, the oscillator start-up timer (ost) is enabled (see section 4.4.1 ?oscillator start-up timer (ost)? ). the ost will suspend program execution until 1024 oscillations are counted. two-speed start-up mode minimizes the delay in code execution by operating from the internal oscillator as the ost is counting. when the ost count reaches 1024 and the osts bit of the osccon register is set, program execution switches to the external oscillator. 4.7.1 two-speed start-up mode configuration two-speed start-up mode is configured by the following settings: ? ieso (of the configuration word register) = 1 ; internal/external switchover bit (two-speed start-up mode enabled). ? scs (of the osccon register) = 0 . ? fosc<2:0> bits in the configuration word register (config) configured for lp, xt or hs mode. two-speed start-up mode is entered after: ? power-on reset (por) and, if enabled, after power-up timer (pwrt) has expired, or ? wake-up from sleep. if the external clock oscillator is configured to be anything other than lp, xt or hs mode, then two-speed start-up is disabled. this is because the external clock oscillator does not require any stabilization time after por or an exit from sleep. 4.7.2 two-speed start-up sequence 1. wake-up from power-on reset or sleep. 2. instructions begin execution by the internal oscillator at the frequency set in the ircf<2:0> bits of the osccon register. 3. ost enabled to count 1024 clock cycles. 4. ost timed out, wait for falling edge of the internal oscillator. 5. osts is set. 6. system clock held low until the next falling edge of new clock (lp, xt or hs mode). 7. system clock is switched to external clock source. note: any automatic clock switch, which may occur from two-speed start-up or fail-safe clock monitor, does not update the scs bit of the osccon register. the user can monitor the osts bit of the osccon register to determine the current system clock source. note: executing a sleep instruction will abort the oscillator start-up time and will cause the osts bit of the osccon register to remain clear.
pic16f913/914/916/917/946 ds41250f-page 96 ? 2007 microchip technology inc. 4.7.3 checking two-speed clock status checking the state of the osts bit of the osccon register will confirm if the microcontroller is running from the external clock source, as defined by the fosc<2:0> bits in the configuration word register (config), or the internal oscillator. figure 4-7: two-speed start-up 0 1 1022 1023 pc + 1 t ost t hfintosc osc1 osc2 program counter system clock pc - n pc
? 2007 microchip technology inc. ds41250f-page 97 pic16f913/914/916/917/946 4.8 fail-safe clock monitor the fail-safe clock monitor (fscm) allows the device to continue operating should the external oscillator fail. the fscm can detect oscillator failure any time after the oscillator start-up timer (ost) has expired. the fscm is enabled by setting the fcmen bit in the configuration word register (config). the fscm is applicable to all external oscillator modes (lp, xt, hs, ec, rc and rcio). figure 4-8: fscm block diagram 4.8.1 fail-safe detection the fscm module detects a failed oscillator by comparing the external oscillator to the fscm sample clock. the sample clock is generated by dividing the lfintosc by 64. see figure 4-8. inside the fail detector block is a latch. the external clock sets the latch on each falling edge of the external clock. the sample clock clears the latch on each rising edge of the sample clock. a failure is detected when an entire half-cycle of the sample clock elapses before the primary clock goes low. 4.8.2 fail-safe operation when the external clock fails, the fscm switches the device clock to an internal clock source and sets the bit flag osfif of the pir2 register. setting this flag will generate an interrupt if the osfie bit of the pie2 register is also set. the device firmware can then take steps to mitigate the problems that may arise from a failed clock. the system clock will continue to be sourced from the internal clock source until the device firmware successfully restarts the external oscillator and switches back to external operation. the internal clock source chosen by the fscm is determined by the ircf<2:0> bits of the osccon register. this allows the internal oscillator to be configured before a failure occurs. 4.8.3 fail-safe condition clearing the fail-safe condition is cleared after a reset, executing a sleep instruction or toggling the scs bit of the osccon register. when the scs bit is toggled, the ost is restarted. while the ost is running, the device continues to operate from the intosc selected in osccon. when the ost times out, the fail-safe condition is cleared and the device will be operating from the external clock source. the fail-safe condition must be cleared before the osfif flag can be cleared. 4.8.4 reset or wake-up from sleep the fscm is designed to detect an oscillator failure after the oscillator start-up timer (ost) has expired. the ost is used after waking up from sleep and after any type of reset. the ost is not used with the ec or rc clock modes so that the fscm will be active as soon as the reset or wake-up has completed. when the fscm is enabled, the two-speed start-up is also enabled. therefore, the device will always be executing code while the ost is operating. external lfintosc 64 s r q 31 khz (~32 s) 488 hz (~2 ms) clock monitor latch clock failure detected oscillator clock q sample clock note: due to the wide range of oscillator start-up times, the fail-safe circuit is not active during oscillator start-up (i.e., after exiting reset or sleep). after an appropriate amount of time, the user should check the osts bit of the osccon register to verify the oscillator start-up and that the system clock switchover has successfully completed.
pic16f913/914/916/917/946 ds41250f-page 98 ? 2007 microchip technology inc. figure 4-9: fscm timing diagram table 4-2: summary of registers asso ciated with clock sources name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets (1) config (2) cpd cp mclre pwrte wdte fosc2 fosc1 fosc0 ? ? intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x osccon ? ircf2 ircf1 ircf0 osts hts lts scs -110 x000 -110 x000 osctune ? ? ? tun4 tun3 tun2 tun1 tun0 ---0 0000 ---u uuuu pie2 osfie c2ie c1ie lcdie ? lvdie ? ccp2ie 0000 -0-0 0000 -0-0 pir2 osfif c2if c1if lcdif ? lvdif ? ccp2if 0000 -0-0 0000 -0-0 t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 0000 0000 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by oscillators. note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: see configuration word register (config) for operation of all register bits. oscfif system clock output sample clock failure detected oscillator failure note: the system clock is normally at a much higher frequency than the sample clock. the relative frequencies in this example have been chosen for clarity. (q) te s t test test clock monitor output
? 2007 microchip technology inc. ds41250f-page 99 pic16f913/914/916/917/946 5.0 timer0 module the timer0 module is an 8-bit timer/counter with the following features: ? 8-bit timer/counter register (tmr0) ? 8-bit prescaler (shared with watchdog timer) ? programmable internal or external clock source ? programmable external clock edge selection ? interrupt on overflow figure 5-1 is a block diagram of the timer0 module. 5.1 timer0 operation when used as a timer, the timer0 module can be used as either an 8-bit timer or an 8-bit counter. 5.1.1 8-bit timer mode when used as a timer, the timer0 module will increment every instruction cycle (without prescaler). timer mode is selected by clearing the t0cs bit of the option register to ? 0 ?. when tmr0 is written, the increment is inhibited for two instruction cycles immediately following the write. 5.1.2 8-bit counter mode when used as a counter, the timer0 module will increment on every rising or falling edge of the t0cki pin. the incrementing edge is determined by the t0se bit of the option register. counter mode is selected by setting the t0cs bit of the option register to ? 1 ?. figure 5-1: block di agram of the timer0/wdt prescaler note: the value written to the tmr0 register can be adjusted, in order to account for the two instruction cycle delay when tmr0 is written. t0cki t0se pin tmr0 watchdog timer wdt time-out ps<2:0> wdte data bus set flag bit t0if on overflow t0cs note 1: t0se, t0cs, psa, ps<2:0> are bits in the option register. 2: swdten and wdtps<3:0> are bits in the wdtcon register. 3: wdte bit is in the configuration word register. 0 1 0 1 0 1 8 8 8-bit prescaler 0 1 f osc /4 psa psa psa 16-bit prescaler 16 wdtps<3:0> 31 khz intosc swdten sync 2 tcy
pic16f913/914/916/917/946 ds41250f-page 100 ? 2007 microchip technology inc. 5.1.3 software programmable prescaler a single software programmable prescaler is available for use with either timer0 or the watchdog timer (wdt), but not both simultaneously. the prescaler assignment is controlled by the psa bit of the option register. to assign the prescaler to timer0, the psa bit must be cleared to a ? 0 ?. there are 8 prescaler options for the timer0 module ranging from 1:2 to 1:256. the prescale values are selectable via the ps<2:0> bits of the option register. in order to have a 1:1 prescaler value for the timer0 module, the prescaler must be assigned to the wdt module. the prescaler is not readable or writable. when assigned to the timer0 module, all instructions writing to the tmr0 register will clear the prescaler. when the prescaler is assigned to wdt, a clrwdt instruction will clear the prescaler along with the wdt. 5.1.3.1 switching prescaler between timer0 and wdt modules as a result of having the prescaler assigned to either timer0 or the wdt, it is possible to generate an unintended device reset when switching prescaler values. when changing the prescaler assignment from timer0 to the wdt module, the instruction sequence shown in example 5-1, must be executed. example 5-1: changing prescaler (timer0 wdt) when changing the prescaler assignment from the wdt to the timer0 module, the following instruction sequence must be executed (see example 5-2). example 5-2: changing prescaler (wdt timer0) 5.1.4 timer0 interrupt timer0 will generate an interrupt when the tmr0 register overflows from ffh to 00h. the t0if interrupt flag bit of the intcon register is set every time the tmr0 register overflows, regardless of whether or not the timer0 interrupt is enabled. the t0if bit must be cleared in software. the timer0 interrupt enable is the t0ie bit of the intcon register. 5.1.5 using timer0 with an external clock when timer0 is in counter mode, the synchronization of the t0cki input and the timer0 register is accom- plished by sampling the prescaler output on the q2 and q4 cycles of the internal phase clocks. therefore, the high and low periods of the external clock source must meet the timing requirements as shown in section 19.0 ?electrical specifications? banksel tmr0 ; clrwdt ;clear wdt clrf tmr0 ;clear tmr0 and ;prescaler banksel option_reg ; bsf option_reg,psa ;select wdt clrwdt ; ; movlw b?11111000? ;mask prescaler andwf option_reg,w ;bits iorlw b?00000101? ;set wdt prescaler movwf option_reg ;to 1:32 note: the timer0 interrupt cannot wake the processor from sleep since the timer is frozen during sleep. clrwdt ;clear wdt and ;prescaler banksel option_reg ; movlw b?11110000? ;mask tmr0 select and andwf option_reg,w ;prescaler bits iorlw b?00000011? ;set prescale to 1:16 movwf option_reg ;
? 2007 microchip technology inc. ds41250f-page 101 pic16f913/914/916/917/946 table 5-1: summary of registers associated with timer0 register 5-1: option_reg: option register r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r bp u intedg t0cs t0se psa ps2 ps1 ps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 r bpu : portb pull-up enable bit 1 = portb pull-ups are disabled 0 = portb pull-ups are enabled by individual port latch values bit 6 intedg: interrupt edge select bit 1 = interrupt on rising edge of int pin 0 = interrupt on falling edge of int pin bit 5 t0cs: tmr0 clock source select bit 1 = transition on t0cki pin 0 = internal instruction cycle clock (f osc /4) bit 4 t0se: tmr0 source edge select bit 1 = increment on high-to-low transition on t0cki pin 0 = increment on low-to-high transition on t0cki pin bit 3 psa: prescaler assignment bit 1 = prescaler is assigned to the wdt 0 = prescaler is assigned to the timer0 module bit 2-0 ps<2:0>: prescaler rate select bits note 1: a dedicated 16-bit wdt postscaler is available. see section 16.4 ?watchdog timer (wdt)? for more information. 000 001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 1 : 1 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 bit value tmr0 rate wdt rate name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets tmr0 timer0 module register xxxx xxxx uuuu uuuu intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x option_reg r b pu intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 legend: - = unimplemented locations, read as ?0?, u = unchanged, x = unknown. shaded cells are not used by the timer0 module.
pic16f913/914/916/917/946 ds41250f-page 102 ? 2007 microchip technology inc. 6.0 timer1 module with gate control the timer1 module is a 16-bit timer/counter with the following features: ? 16-bit timer/counter register pair (tmr1h:tmr1l) ? programmable internal or external clock source ? 3-bit prescaler ? optional lp oscillator ? synchronous or asynchronous operation ? timer1 gate (count enable) via comparator or t1g pin ? interrupt on overflow ? wake-up on overflow (external clock, asynchronous mode only) ? clock source for lcd module figure 6-1 is a block diagram of the timer1 module. 6.1 timer1 operation the timer1 module is a 16-bit incrementing counter which is accessed through the tmr1h:tmr1l register pair. writes to tmr1h or tmr1l directly update the counter. when used with an internal clock source, the module is a timer. when used with an external clock source, the module can be used as either a timer or counter. 6.2 clock source selection the tmr1cs bit of the t1con register is used to select the clock source. when tmr1cs = 0 , the clock source is f osc /4. when tmr1cs = 1 , the clock source is supplied externally. figure 6-1: timer1 block diagram clock source tmr1cs f osc /4 0 t1cki pin 1 tmr1h tmr1l t1sync t1ckps<1:0> prescaler 1, 2, 4, 8 0 1 synchronized clock input 2 set flag bit tmr1if on overflow tmr1 (2) tmr1ge tmr1on 1 0 syncc2out (4) t1gss t1ginv to c2 comparator module timer1 clock note 1: st buffer is low power type when using lp oscillator, or high speed type when using t1cki. 2: timer1 register increments on rising edge. 3: synchronize does not operate while in sleep. 4: syncc2out is synchronized when the c2sync bit of the cmcon1 register is set. en t1g lp osc f osc /4 internal clock 1 0 osc1/t1osi osc2/t1oso f osc = 000 t1oscen f osc = x00 1 0 t1cki tmr1cs (1) to lcd module synchronize (3) det
? 2007 microchip technology inc. ds41250f-page 103 pic16f913/914/916/917/946 6.2.1 internal clock source when the internal clock source is selected, the tmr1h:tmr1l register pair will increment on multiples of t cy as determined by the timer1 prescaler. 6.2.2 external clock source when the external clock source is selected, the timer1 module may work as a timer or a counter. when counting, timer1 is incremented on the rising edge of the external clock input t1cki. in addition, the counter mode clock can be synchronized to the microcontroller system clock or run asynchronously. in counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge after one or more of the following conditions: ? timer1 is enabled after por or bor reset ? a write to tmr1h or tmr1l ? t1cki is high when timer1 is disabled and when timer1 is reenabled t1cki is low. see figure 6-2. 6.3 timer1 prescaler timer1 has four prescaler options allowing 1, 2, 4 or 8 divisions of the clock input. the t1ckps bits of the t1con register control the prescale counter. the prescale counter is not directly readable or writable; however, the prescaler counter is cleared upon a write to tmr1h or tmr1l. 6.4 timer1 oscillator a low-power 32.768 khz crystal oscillator is built-in between pins osc1 (input) and osc2 (amplifier output). the oscillator is enabled by setting the t1oscen control bit of the t1con register. the oscillator will continue to run during sleep. the timer1 oscillator is shared with the system lp oscillator. thus, timer1 can use this mode only when the primary system clock is derived from the internal oscillator or when in lp oscillator mode. the user must provide a software time delay to ensure proper oscilla- tor start-up. trisa7 and trisa6 bits are set when the timer1 oscillator is enabled. ra7 and ra6 bits read as ? 0 ? and trisa7 and trisa6 bits read as ? 1 ?. 6.5 timer1 operation in asynchronous counter mode if control bit t1sync of the t1con register is set, the external clock input is not synchronized. the timer continues to increment asynchronous to the internal phase clocks. the timer will continue to run during sleep and can generate an interrupt on overflow, which will wake-up the processor. however, special precautions in software are needed to read/write the timer (see section 6.5.1 ?reading and writing timer1 in asynchronous counter mode? ). 6.5.1 reading and writing timer1 in asynchronous counter mode reading tmr1h or tmr1l while the timer is running from an external asynchronous clock will ensure a valid read (taken care of in hardware). however, the user should keep in mind that reading the 16-bit timer in two 8-bit values itself poses certain problems, since the timer may overflow between the reads. for writes, it is recommended that the user simply stop the timer and write the desired values. a write contention may occur by writing to the timer registers, while the register is incrementing. this may produce an unpredictable value in the tmr1h:tmr1l register pair. 6.6 timer1 gate timer1 gate source is software configurable to be the t1g pin or the output of comparator c2. this allows the device to directly time external events using t1g or analog events using comparator c2. see the cmcon1 register (register 8-2) for selecting the timer1 gate source. this feature can simplify the software for a delta-sigma a/d converter and many other applications. for more information on delta-sigma a/d converters, see the microchip web site (www.microchip.com). timer1 gate can be inverted using the t1ginv bit of the t1con register, whether it originates from the t1g pin or comparator c2 output. this configures timer1 to measure either the active-high or active-low time between events. note: the oscillator requires a start-up and stabilization time before use. thus, t1oscen should be set and a suitable delay observed prior to enabling timer1. note 1: when switching from synchronous to asynchronous operation, it is possible to skip an increment. when switching from asynchronous to synchronous operation, it is possible to produce an additional increment. note: tmr1ge bit of the t1con register must be set to use the timer1 gate.
pic16f913/914/916/917/946 ds41250f-page 104 ? 2007 microchip technology inc. 6.7 timer1 interrupt the timer1 register pair (tmr1h:tmr1l) increments to ffffh and rolls over to 0000h. when timer1 rolls over, the timer1 interrupt flag bit of the pir1 register is set. to enable the interrupt on rollover, you must set these bits: ? timer1 interrupt enable bit of the pie1 register ? peie bit of the intcon register ? gie bit of the intcon register the interrupt is cleared by clearing the tmr1if bit in the interrupt service routine. 6.8 timer1 operation during sleep timer1 can only operate during sleep when setup in asynchronous counter mode. in this mode, an external crystal or clock source can be used to increment the counter. to set up the timer to wake the device: ? tmr1on bit of the t1con register must be set ? tmr1ie bit of the pie1 register must be set ? peie bit of the intcon register must be set the device will wake-up on an overflow and execute the next instruction. if the gie bit of the intcon register is set, the device will call the interrupt service routine (0004h). 6.9 clock source for lcd module the timer1 oscillator can be used to provide a clock for the lcd module. this clock may be configured to remain running during sleep. for more information, see section 10.0 ?liquid crys- tal display (lcd) driver module? . figure 6-2: timer1 incrementing edge note: the tmr1h:tmr1l register pair and the tmr1if bit should be cleared before enabling interrupts. t1cki = 1 when tmr1 enabled t1cki = 0 when tmr1 enabled note 1: arrows indicate counter increments. 2: in counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge of the clock.
? 2007 microchip technology inc. ds41250f-page 105 pic16f913/914/916/917/946 6.10 timer1 control register the timer1 control register (t1con), shown in register 6-1, is used to control timer1 and select the various features of the timer1 module. register 6-1: t1con: ti mer 1 control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 t1ginv (1) tmr1ge (2) t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 t1ginv: timer1 gate invert bit (1) 1 = timer1 gate is active-high (timer1 counts when gate is high) 0 = timer1 gate is active-low (timer1 counts when gate is low) bit 6 tmr1ge: timer1 gate enable bit (2) if tmr1on = 0 : this bit is ignored if tmr1on = 1 : 1 = timer1 counting is controlled by the timer1 gate function 0 = timer1 is always counting bit 5-4 t1ckps<1:0>: timer1 input clock prescale select bits 11 = 1:8 prescale value 10 = 1:4 prescale value 01 = 1:2 prescale value 00 = 1:1 prescale value bit 3 t1oscen: lp oscillator enable control bit if intosc without clkout oscillator is active: 1 = lp oscillator is enabled for timer1 clock 0 = lp oscillator is off else: this bit is ignored. lp oscillator is disabled. bit 2 t1sync : timer1 external clock input synchronization control bit tmr1cs = 1 : 1 = do not synchronize external clock input 0 = synchronize external clock input tmr1cs = 0 : this bit is ignored. timer1 uses the internal clock. bit 1 tmr1cs: timer1 clock source select bit 1 = external clock from t1cki pin (on the rising edge) 0 = internal clock (f osc /4) bit 0 tmr1on: timer1 on bit 1 = enables timer1 0 = stops timer1 note 1: t1ginv bit inverts the timer1 gate logic, regardless of source. 2: tmr1ge bit must be set to use either t1g pin or c2out, as selected by the t1gss bit of the cmcon1 register, as a timer1 gate source.
pic16f913/914/916/917/946 ds41250f-page 106 ? 2007 microchip technology inc. table 6-1: summary of registers associated with timer1 name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets cmcon1 ? ? ? ? ? ? t1gss c2sync ---- --10 ---- --10 intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 uuuu uuuu legend: x = unknown, u = unchanged, - = unimplemented, read as ? 0 ?. shaded cells are not used by the timer1 module.
? 2007 microchip technology inc. ds41250f-page 107 pic16f913/914/916/917/946 7.0 timer2 module the timer2 module is an 8-bit timer with the following features: ? 8-bit timer register (tmr2) ? 8-bit period register (pr2) ? interrupt on tmr2 match with pr2 ? software programmable prescaler (1:1, 1:4, 1:16) ? software programmable postscaler (1:1 to 1:16) see figure 7-1 for a block diagram of timer2. 7.1 timer2 operation the clock input to the timer2 module is the system instruction clock (f osc /4). the clock is fed into the timer2 prescaler, which has prescale options of 1:1, 1:4 or 1:16. the output of the prescaler is then used to increment the tmr2 register. the values of tmr2 and pr2 are constantly compared to determine when they match. tmr2 will increment from 00h until it matches the value in pr2. when a match occurs, two things happen: ? tmr2 is reset to 00h on the next increment cycle. ? the timer2 postscaler is incremented. the match output of the timer2/pr2 comparator is then fed into the timer2 postscaler. the postscaler has postscale options of 1:1 to 1:16 inclusive. the output of the timer2 postscaler is used to set the tmr2if interrupt flag bit in the pir1 register. the tmr2 and pr2 registers are both fully readable and writable. on any reset, the tmr2 register is set to 00h and the pr2 register is set to ffh. timer2 is turned on by setting the tmr2on bit in the t2con register to a ? 1 ?. timer2 is turned off by clearing the tmr2on bit to a ? 0 ?. the timer2 prescaler is controlled by the t2ckps bits in the t2con register. the timer2 postscaler is controlled by the toutps bits in the t2con register. the prescaler and postscaler counters are cleared when: ? a write to tmr2 occurs. ? a write to t2con occurs. ? any device reset occurs (power-on reset, mclr reset, watchdog timer reset, or brown-out reset). figure 7-1: timer2 block diagram note: tmr2 is not cleared when t2con is written. comparator tmr2 sets flag tmr2 output reset postscaler prescaler pr2 2 f osc /4 1:1 to 1:16 1:1, 1:4, 1:16 eq 4 bit tmr2if toutps<3:0> t2ckps<1:0>
pic16f913/914/916/917/946 ds41250f-page 108 ? 2007 microchip technology inc. table 7-1: summary of registers associated with timer2 register 7-1: t2con: ti mer 2 control register u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 unimplemented: read as ? 0 ? bit 6-3 toutps<3:0>: timer2 output postscaler select bits 0000 = 1:1 postscaler 0001 = 1:2 postscaler 0010 = 1:3 postscaler 0011 = 1:4 postscaler 0100 = 1:5 postscaler 0101 = 1:6 postscaler 0110 = 1:7 postscaler 0111 = 1:8 postscaler 1000 = 1:9 postscaler 1001 = 1:10 postscaler 1010 = 1:11 postscaler 1011 = 1:12 postscaler 1100 = 1:13 postscaler 1101 = 1:14 postscaler 1110 = 1:15 postscaler 1111 = 1:16 postscaler bit 2 tmr2on: timer2 on bit 1 = timer2 is on 0 = timer2 is off bit 1-0 t2ckps<1:0>: timer2 clock prescale select bits 00 =prescaler is 1 01 =prescaler is 4 1x = prescaler is 16 name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pr2 timer2 module period register 1111 1111 1111 1111 tmr2 holding register for the 8-bit tmr2 register 0000 0000 0000 0000 t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 legend: x = unknown, u = unchanged, - = unimplemented read as ? 0 ?. shaded cells are not used for timer2 module.
? 2007 microchip technology inc. ds41250f-page 109 pic16f913/914/916/917/946 8.0 comparator module comparators are used to interface analog circuits to a digital circuit by comparing two analog voltages and providing a digital indication of their relative magnitudes. the comparators are very useful mixed signal building blocks because they provide analog functionality independent of the program execution. the analog comparator module includes the following features: ? dual comparators ? multiple comparator configurations ? comparator outputs are available internally/externally ? programmable output polarity ? interrupt-on-change ? wake-up from sleep ? timer1 gate (count enable) ? output synchronization to timer1 clock input ? programmable voltage reference 8.1 comparator overview a comparator is shown in figure 8-1 along with the relationship between the analog input levels and the digital output. when the analog voltage at v in + is less than the analog voltage at v in -, the output of the comparator is a digital low level. when the analog voltage at v in + is greater than the analog voltage at v in -, the output of the comparator is a digital high level. figure 8-1: single comparator this device contains two comparators as shown in figure 8-2 and figure 8-3. the comparators are not independently configurable. note: only comparator c2 can be linked to timer1. ? + v in + v in - output output v in + v in - note: the black areas of the output of the comparator represents the uncertainty due to input offsets and response time.
pic16f913/914/916/917/946 ds41250f-page 110 ? 2007 microchip technology inc. figure 8-2: comparator c1 output block diagram figure 8-3: comparator c2 output block diagram dq en to c 1 o u t p i n rd cmcon0 set c1if bit multiplex port pins q3*rd cmcon0 reset to d a ta b u s c1inv dq en cl q1 note 1: q1 and q3 are phases of the four-phase system clock (f osc ). 2: q1 is held high during sleep mode. c1 c2sync dq en to c2out pin rd cmcon0 set c2if bit multiplex port pins q3*rd cmcon0 reset to data bus c2inv timer1 clock source (1) 0 1 to syncc2out dq dq en cl q1 note 1: comparator output is latched on falling edge of timer1 clock source. 2: q1 and q3 are phases of the four-phase system clock (f osc ). 3: q1 is held high during sleep mode. c2
? 2007 microchip technology inc. ds41250f-page 111 pic16f913/914/916/917/946 8.1.1 analog input connection considerations a simplified circuit for an analog input is shown in figure 8-4. since the analog input pins share their con- nection with a digital input, they have reverse biased esd protection diodes to v dd and v ss . the analog input, therefore, must be between v ss and v dd . if the input voltage deviates from this range by more than 0.6v in either direction, one of the diodes is forward biased and a latch-up may occur. a maximum source impedance of 10 k is recommended for the analog sources. also, any external component connected to an analog input pin, such as a capacitor or a zener diode, should have very little leakage current to minimize inaccuracies introduced. figure 8-4: analog input model note 1: when reading a port register, all pins configured as analog inputs will read as a ? 0 ?. pins configured as digital inputs will convert as an analog input, according to the input specification. 2: analog levels on any pin defined as a digital input, may cause the input buffer to consume more current than is specified. v a rs < 10k c pin 5 pf v dd v t 0.6v v t 0.6v r ic i leakage 500 na vss a in legend: c pin = input capacitance i leakage = leakage current at the pin due to various junctions r ic = interconnect resistance r s = source impedance v a = analog voltage v t = threshold voltage to comparator
pic16f913/914/916/917/946 ds41250f-page 112 ? 2007 microchip technology inc. 8.2 comparator configuration there are eight modes of operation for the comparator. the cm<2:0> bits of the cmcon0 register are used to select these modes as shown in figure 8-5. i/o lines change as a function of the mode and are designated as follows: ? analog function (a): digital input buffer is disabled ? digital function (d): comparator digital output, overrides port function ? normal port function (i/o): independent of comparator the port pins denoted as ?a? will read as a ? 0 ? regardless of the state of the i/o pin or the i/o control tris bit. pins used as analog inputs should also have the corresponding tris bit set to ? 1 ? to disable the digital output driver. pins denoted as ?d? should have the corresponding tris bit set to ? 0 ? to enable the digital output driver. note: comparator interrupts should be disabled during a comparator mode change to prevent unintended interrupts.
? 2007 microchip technology inc. ds41250f-page 113 pic16f913/914/916/917/946 figure 8-5: comparator i/o operating modes legend: a = analog input, ports always reads ? 0 ? cis = comparator input switch (cmcon0<3>) i/o = normal port i/o d = comparator digital output c1 c1in- v in - v in + c1in+ off (read as ? 0 ?) comparators reset (por default value) a a cm<2:0> = 000 c2 c2in- v in - v in + c2in+ off (read as ? 0 ?) a a c1 c1in- v in - v in + c1in+ c1out two independent comparators a a cm<2:0> = 100 c2 c2in- v in - v in + c2in+ c2out a a c1 c1in- v in - v in + c1in+ c1out two common reference comparators a i/o cm<2:0> = 011 c2 c2in- v in - v in + c2in+ c2out a a c1 c1in- v in - v in + c1in+ off (read as ? 0 ?) one independent comparator with reference option i/o i/o cm<2:0> = 101 c2 c2in- v in - v in + c2out a c1 c1in- v in - v in + c1in+ off (read as ? 0 ?) comparators off (lowest power) i/o i/o cm<2:0> = 111 c2 c2in- v in - v in + c2in+ off (read as ? 0 ?) i/o i/o c1 c1in- v in - v in + c1in+ c1out four inputs multiplexed to two comparators a a cm<2:0> = 010 c2 c2in- v in - v in + c2in+ c2out a a from cv ref module cis = 0 cis = 1 cis = 0 cis = 1 c1 c1in- v in - v in + c1out(pin) c1out two common reference comparators with outputs a d cm<2:0> = 110 c2 c2in- v in - v in + c2in+ c2out a a c2out(pin) c1 c1in- v in - v in + c1in+ c1out three inputs multiplexed to two comparators a a cm<2:0> = 001 c2 c2in- v in - v in + c2in+ c2out a a cis = 0 cis = 1 d c2in+ a cis = 0 cis = 1 c2out(pin) internal fixed voltage ref
pic16f913/914/916/917/946 ds41250f-page 114 ? 2007 microchip technology inc. 8.3 comparator control the cmcon0 register (register 8-1) provides access to the following comparator features: ? mode selection ? output state ? output polarity ? input switch 8.3.1 comparator output state each comparator state can always be read internally via the associated cxout bit of the cmcon0 register. the comparator outputs are directed to the cxout pins when cm<2:0> = 110 . when this mode is selected, the tris bits for the associated cxout pins must be cleared to enable the output drivers. 8.3.2 comparator output polarity inverting the output of a comparator is functionally equivalent to swapping the comparator inputs. the polarity of a comparator output can be inverted by set- ting the cxinv bits of the cmcon0 register. clearing cxinv results in a non-inverted output. a complete table showing the output state versus input conditions and the polarity bit is shown in table 8-1. table 8-1: output state vs. input conditions 8.3.3 comparator input switch the inverting input of the comparators may be switched between two analog pins or an analog input pin and and the fixed voltage reference in the following modes: ? cm<2:0> = 001 (comparator c1 only) ? cm<2:0> = 010 (comparators c1 and c2) ? cm<2:0> = 101 (comparator c2 only) in the above modes, both pins remain in analog mode regardless of which pin is selected as the input. the cis bit of the cmcon0 register controls the comparator input switch. 8.4 comparator response time the comparator output is indeterminate for a period of time after the change of an input source or the selection of a new reference voltage. this period is referred to as the response time. the response time of the comparator differs from the settling time of the voltage reference. therefore, both of these times must be considered when determining the total response time to a comparator input change. see the comparator and voltage reference specifications in section 19.0 ?electrical specifications? for more details. 8.5 comparator interrupt operation the comparator interrupt flag is set whenever there is a change in the output value of the comparator. changes are recognized by means of a mismatch circuit which consists of two latches and an exclusive-or gate (see figure 8-2 and figure 8-3). one latch is updated with the comparator output level when the cmcon0 register is read. this latch retains the value until the next read of the cmcon0 register or the occurrence of a reset. the other latch of the mismatch circuit is updated on every q1 system clock. a mismatch condition will occur when a comparator output change is clocked through the second latch on the q1 clock cycle. the mismatch condition will persist, holding the cxif bit of the pir2 register true, until either the cmcon0 register is read or the comparator output returns to the previous state. software will need to maintain information about the status of the comparator output to determine the actual change that has occurred. the cxif bit of the pir2 register is the comparator interrupt flag. this bit must be reset in software by clearing it to ? 0 ?. since it is also possible to write a ? 1 ? to this register, a simulated interrupt may be initiated. the cxie bit of the pie2 register and the peie and gie bits of the intcon register must all be set to enable comparator interrupts. if any of these bits are cleared, the interrupt is not enabled, although the cxif bit of the pir2 register will still be set if an interrupt condition occurs. the user, in the interrupt service routine, can clear the interrupt in the following manner: a) any read or write of cmcon0. this will end the mismatch condition. see figures 8-6 and 8-7 b) clear the cxif interrupt flag. a persistent mismatch condition will preclude clearing the cxif interrupt flag. reading cmcon0 will end the mismatch condition and allow the cxif bit to be cleared. input conditions cxinv cxout v in - > v in + 00 v in - < v in + 01 v in - > v in + 11 v in - < v in + 10 note: cxout refers to both the register bit and output pin. note: a write operation to the cmcon0 register will also clear the mismatch condition because all writes include a read operation at the beginning of the write cycle.
? 2007 microchip technology inc. ds41250f-page 115 pic16f913/914/916/917/946 figure 8-6: comparator interrupt timing w/o cmcon0 read figure 8-7: comparator interrupt timing with cmcon0 read 8.6 operation during sleep the comparator, if enabled before entering sleep mode, remains active during sleep. the additional current consumed by the comparator is shown separately in the section 19.0 ?electrical specifications? . if the comparator is not used to wake the device, power consumption can be minimized while in sleep mode by turning off the comparator. the comparator is turned off by selecting mode cm<2:0> = 000 or cm<2:0> = 111 of the cmcon0 register. a change to the comparator output can wake-up the device from sleep. to enable the comparator to wake the device from sleep, the cxie bit of the pie2 register and the peie bit of the intcon register must be set. the instruction following the sleep instruction always executes following a wake from sleep. if the gie bit of the intcon register is also set, the device will then execute the interrupt service routine. 8.7 effects of a reset a device reset forces the cmcon0 and cmcon1 registers to their reset states. this forces the compar- ator module to be in the comparator reset mode (cm<2:0> = 000) . thus, all comparator inputs are analog inputs with the comparator disabled to consume the smallest current possible. note 1: if a change in the cmcon0 register (cxout) occurs when a read operation is being executed (start of the q2 cycle), then the cxif interrupt flag bit of the pir2 register may not get set. 2: when either comparator is first enabled, bias circuitry in the comparator module may cause an invalid output from the comparator until the bias circuitry is stable. allow about 1 s for bias settling then clear the mismatch condition and interrupt flags before enabling comparator interrupts. q1 q3 c in + c out set cxif (level) cxif t rt reset by software q1 q3 c in + c out set cxif (level) cxif t rt reset by software cleared by cmcon0 read
pic16f913/914/916/917/946 ds41250f-page 116 ? 2007 microchip technology inc. register 8-1: cmcon0: compara tor configuration register r-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 c2out: comparator 2 output bit when c2inv = 0 : 1 = c2 v in + > c2 v in - 0 = c2 v in + < c2 v in - when c2inv = 1 : 1 = c2 v in + < c2 v in - 0 = c2 v in + > c2 v in - bit 6 c1out: comparator 1 output bit when c1inv = 0 : 1 = c1 v in + > c1 v in - 0 = c1 v in + < c1 v in - when c1inv = 1 : 1 = c1 v in + < c1 v in - 0 = c1 v in + > c1 v in - bit 5 c2inv: comparator 2 output inversion bit 1 = c2 output inverted 0 = c2 output not inverted bit 4 c1inv: comparator 1 output inversion bit 1 = c1 output inverted 0 = c1 output not inverted bit 3 cis: comparator input switch bit when cm<2:0> = 010 : 1 = c1in+ connects to c1 v in - c2in+ connects to c2 v in - 0 = c1in- connects to c1 v in - c2in- connects to c2 v in - when cm<2:0> = 001 : 1 = c1in+ connects to c1 v in - 0 = c1in- connects to c1 v in - when cm<2:0> = 101 : (16f91x/946) 1 = c2 v in + connects to fixed voltage reference 0 = c2 v in + connects to c2in+ bit 2-0 cm<2:0>: comparator mode bits (see figure 8-5) 000 = comparators off. cxin pins are configured as analog 001 = three inputs multiplexed to two comparators 010 = four inputs multiplexed to two comparators 011 = two common reference comparators 100 = two independent comparators 101 = one independent comparator 110 = two comparators with outputs and common reference 111 = comparators off. cxin pins are configured as digital i/o
? 2007 microchip technology inc. ds41250f-page 117 pic16f913/914/916/917/946 8.8 comparator c2 gating timer1 this feature can be used to time the duration or interval of analog events. clearing the t1gss bit of the cmcon1 register will enable timer1 to increment based on the output of comparator c2. this requires that timer1 is on and gating is enabled. see section 6.0 ?timer1 module with gate control? for details. it is recommended to synchronize comparator c2 with timer1 by setting the c2sync bit when the comparator is used as the timer1 gate source. this ensures timer1 does not miss an increment if the comparator changes during an increment. 8.9 synchronizing comparator c2 output to timer1 the output of comparator c2 can be synchronized with timer1 by setting the c2sync bit of the cmcon1 register. when enabled, the comparator output is latched on the falling edge of the timer1 clock source. if a prescaler is used with timer1, the comparator output is latched after the prescaling function. to prevent a race condition, the comparator output is latched on the falling edge of the timer1 clock source and timer1 increments on the rising edge of its clock source. reference the comparator block diagrams (figure 8-2 and figure 8-3) and the timer1 block diagram (figure 6-1) for more information. register 8-2: cmcon1: compara tor configuration register u-0 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 ? ? ? ? ? ? t1gss c2sync bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-2 unimplemented: read as ? 0 ? bit 1 t1gss: timer1 gate source select bit (1) 1 = timer1 gate source is t1g pin (pin should be configured as digital input) 0 = timer1 gate source is comparator c2 output bit 0 c2sync: comparator c2 output synchronization bit (2) 1 = output is synchronized with falling edge of timer1 clock 0 = output is asynchronous note 1: refer to section 6.6 ?timer1 gate? . 2: refer to figure 8-3.
pic16f913/914/916/917/946 ds41250f-page 118 ? 2007 microchip technology inc. 8.10 comparator voltage reference the comparator voltage reference module provides an internally generated voltage reference for the com- parators. the following features are available: ? independent from comparator operation ? two 16-level voltage ranges ? output clamped to v ss ? ratiometric with v dd the vrcon register (register 8-3) controls the voltage reference module shown in figure 8-8. 8.10.1 independent operation the comparator voltage reference is independent of the comparator configuration. setting the vren bit of the vrcon register will enable the voltage reference. 8.10.2 output voltage selection the cv ref voltage reference has 2 ranges with 16 voltage levels in each range. range selection is controlled by the vrr bit of the vrcon register. the 16 levels are set with the vr<3:0> bits of the vrcon register. the cv ref output voltage is determined by the following equations: equation 8-1: cv ref output voltage the full range of v ss to v dd cannot be realized due to the construction of the module. see figure 8-8. 8.10.3 output clamped to v ss the cv ref output voltage can be set to vss with no power consumption by configuring vrcon as follows: ?vren= 0 ?vrr= 1 ?vr<3:0>= 0000 this allows the comparator to detect a zero-crossing while not consuming additional cv ref module current. 8.10.4 output ratiometric to vdd the comparator voltage reference is v dd derived and therefore, the cv ref output changes with fluctuations in v dd . the tested absolute accuracy of the comparator voltage reference can be found in section 19.0 ?electrical specifications? . v rr 1 (low range): = v rr 0 (high range): = cv ref (v dd /4) + = cv ref (vr<3:0>/24) v dd = (vr<3:0> v dd /32) register 8-3: vrcon: voltage reference control register r/w-0 u-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 vren ?vrr ? vr3 vr2 vr1 vr0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 vren: cv ref enable bit 1 = cv ref circuit powered on 0 = cv ref circuit powered down, no i dd drain and cv ref = v ss . bit 6 unimplemented: read as ? 0 ? bit 5 vrr: cv ref range selection bit 1 = low range 0 = high range bit 4 unimplemented: read as ? 0 ? bit 3-0 vr<3:0>: cv ref value selection bits (0 vr<3:0> 15) when v rr = 1 : cv ref = (vr<3:0>/24) * v dd when v rr = 0 : cv ref = v dd /4 + (vr<3:0>/32) * v dd
? 2007 microchip technology inc. ds41250f-page 119 pic16f913/914/916/917/946 figure 8-8: comparator volt age reference block diagram table 8-2: summary of registers associ ated with the comparator and voltage reference modules name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets ansel ans7 ans6 ans5 ans4 ans3 ans2 ans1 ans0 1111 1111 1111 1111 cmcon0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 0000 0000 cmcon1 ? ? ? ? ? ? t1gss c2sync ---- --10 ---- --10 intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie2 osfie c2ie c1ie lcdie ? lvdie ? ccp2ie 0000 -0-0 0000 -0-0 pir2 osfif c2if c1if lcdif ? lvdif ? ccp2if 0000 -0-0 0000 -0-0 porta ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 xxxx xxxx uuuu uuuu trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 vrcon vren ?vrr ? vr3 vr2 vr1 vr0 0-0- 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as ? 0 ?. shaded cells are not used for comparator. vrr 8r vr<3:0> (1) 16-1 analog 8rrr rr cv ref to 16 stages comparator input vren v dd mux vr<3:0> = 0000 vren vrr 0 1 2 14 15 note 1: care should be taken to ensure v ref remains within the comparator common mode input range. see section 19.0 ?electrical specifications? for more detail.
pic16f913/914/916/917/946 ds41250f-page 120 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 121 pic16f913/914/916/917/946 9.0 addressable universal synchronous asynchronous receiver transmitter (ausart) the addressable universal synchronous asynchronous receiver transmitter (ausart) module is a serial i/o communications peripheral. it contains all the clock generators, shift registers and data buffers necessary to perform an input or output serial data transfer independent of device program execution. the ausart, also known as a serial communications interface (sci), can be configured as a full-duplex asynchronous system or half-duplex synchronous system. full-duplex mode is useful for communications with peripheral systems, such as crt terminals and personal computers. half-duplex synchronous mode is intended for communications with peripheral devices, such as a/d or d/a integrated circuits, serial eeproms or other microcontrollers. these devices typically do not have internal clocks for baud rate generation and require the external clock signal provided by a master synchronous device. the ausart module includes the following capabilities: ? full-duplex asynchronous transmit and receive ? two-character input buffer ? one-character output buffer ? programmable 8-bit or 9-bit character length ? address detection in 9-bit mode ? input buffer overrun error detection ? received character framing error detection ? half-duplex synchronous master ? half-duplex synchronous slave ? sleep operation block diagrams of the ausart transmitter and receiver are shown in figure 9-1 and figure 9-2. figure 9-1: ausart transmit block diagram txif txie interrupt txen tx9d msb lsb data bus txreg register transmit shift register (tsr) (8) 0 tx9 trmt spen tx/ck pin pin buffer and control 8 spbrg f osc n n + 1 multiplier x4 x16 x64 sync 100 brgh x10 baud rate generator ???
pic16f913/914/916/917/946 ds41250f-page 122 ? 2007 microchip technology inc. figure 9-2: ausart recei ve block diagram the operation of the ausart module is controlled through two registers: ? transmit status and control (txsta) ? receive status and control (rcsta) these registers are detailed in register 9-1 and register 9-2 respectively. rx/dt pin pin buffer and control spen data recovery cren oerr ferr rsr register msb lsb rx9d rcreg register fifo interrupt rcif rcie data bus 8 stop start (8) 7 1 0 rx9 ? ? ? spbrg f osc n n + 1 multiplier x4 x16 x64 sync 100 brgh x10 baud rate generator
? 2007 microchip technology inc. ds41250f-page 123 pic16f913/914/916/917/946 9.1 ausart asynchronous mode the ausart transmits and receives data using the standard non-return-to-zero (nrz) format. nrz is implemented with two levels: a v oh mark state which represents a ? 1 ? data bit, and a v ol space state which represents a ? 0 ? data bit. nrz refers to the fact that consecutively transmitted data bits of the same value stay at the output level of that bit without returning to a neutral level between each bit transmission. an nrz transmission port idles in the mark state. each character transmission consists of one start bit followed by eight or nine data bits and is always terminated by one or more stop bits. the start bit is always a space and the stop bits are always marks. the most common data format is 8 bits. each transmitted bit persists for a period of 1/(baud rate). an on-chip dedicated 8-bit baud rate generator is used to derive standard baud rate frequencies from the system oscillator. see table 9-5 for examples of baud rate configurations. the ausart transmits and receives the lsb first. the ausart?s transmitter and receiver are functionally independent, but share the same data format and baud rate. parity is not supported by the hardware, but can be implemented in software and stored as the ninth data bit. 9.1.1 ausart asynchronous transmitter the ausart transmitter block diagram is shown in figure 9-1. the heart of the transmitter is the serial transmit shift register (tsr), which is not directly accessible by software. the tsr obtains its data from the transmit buffer, which is the txreg register. 9.1.1.1 enabling the transmitter the ausart transmitter is enabled for asynchronous operations by configuring the following three control bits: ?txen = 1 ? sync = 0 ? spen = 1 all other ausart control bits are assumed to be in their default state. setting the txen bit of the txsta register enables the transmitter circuitry of the ausart. clearing the sync bit of the txsta register configures the ausart for asynchronous operation. setting the spen bit of the rcsta register enables the ausart and automatically configures the tx/ck i/o pin as an output. the lcd seg9 function must be disabled by clearing the se9 bit of the lcdse1 register, if the tx/ck pin is shared with the lcd peripheral. 9.1.1.2 transmitting data a transmission is initiated by writing a character to the txreg register. if this is the first character, or the previous character has been completely flushed from the tsr, the data in the txreg is immediately transferred to the tsr register. if the tsr still contains all or part of a previous character, the new character data is held in the txreg until the stop bit of the previous character has been transmitted. the pending character in the txreg is then transferred to the tsr in one t cy immediately following the stop bit transmission. the transmission of the start bit, data bits and stop bit sequence commences immediately following the transfer of the data to the tsr from the txreg. 9.1.1.3 transmit interrupt flag the txif interrupt flag bit of the pir1 register is set whenever the ausart transmitter is enabled and no character is being held for transmission in the txreg. in other words, the txif bit is only clear when the tsr is busy with a character and a new character has been queued for transmission in the txreg. the txif flag bit is not cleared immediately upon writing txreg. txif becomes valid in the second instruction cycle following the write execution. polling txif immediately following the txreg write will return invalid results. the txif bit is read-only, it cannot be set or cleared by software. the txif interrupt can be enabled by setting the txie interrupt enable bit of the pie1 register. however, the txif flag bit will be set whenever the txreg is empty, regardless of the state of txie enable bit. to use interrupts when transmitting data, set the txie bit only when there is more data to send. clear the txie interrupt enable bit upon writing the last character of the transmission to the txreg. note 1: when the spen bit is set the rx/dt i/o pin is automatically configured as an input, regardless of the state of the corresponding tris bit and whether or not the ausart receiver is enabled. the rx/dt pin data can be read via a normal port read but port latch data output is precluded. 2: the txif transmitter interrupt flag is set when the txen enable bit is set.
pic16f913/914/916/917/946 ds41250f-page 124 ? 2007 microchip technology inc. 9.1.1.4 tsr status the trmt bit of the txsta register indicates the status of the tsr register. this is a read-only bit. the trmt bit is set when the tsr register is empty and is cleared when a character is transferred to the tsr register from the txreg. the trmt bit remains clear until all bits have been shifted out of the tsr register. no interrupt logic is tied to this bit, so the user has to poll this bit to determine the tsr status. 9.1.1.5 transmitting 9-bit characters the ausart supports 9-bit character transmissions. when the tx9 bit of the txsta register is set the ausart will shift 9 bits out for each character transmit- ted. the tx9d bit of the txsta register is the ninth, and most significant, data bit. when transmitting 9-bit data, the tx9d data bit must be written before writing the 8 least significant bits into the txreg. all nine bits of data will be transferred to the tsr shift register immediately after the txreg is written. a special 9-bit address mode is available for use with multiple receivers. see section 9.1.2.7 ?address detection? for more information on the address mode. 9.1.1.6 asynchronous transmission set-up: 1. initialize the spbrg register and the brgh bit to achieve the desired baud rate (see section 9.2 ?ausart baud rate generator (brg)? ). 2. enable the asynchronous serial port by clearing the sync bit and setting the spen bit. 3. if 9-bit transmission is desired, set the tx9 con- trol bit. a set ninth data bit will indicate that the 8 least significant data bits are an address when the receiver is set for address detection. 4. enable the transmission by setting the txen control bit. this will cause the txif interrupt bit to be set. 5. if interrupts are desired, set the txie interrupt enable bit of the pie1 register. an interrupt will occur immediately provided that the gie and peie bits of the intcon register are also set. 6. if 9-bit transmission is selected, the ninth bit should be loaded into the tx9d data bit. 7. load 8-bit data into the txreg register. this will start the transmission. figure 9-3: asynchronous transmission figure 9-4: asynchronous transmiss ion (back-to-back) note: the tsr register is not mapped in data memory, so it is not available to the user. word 1 stop bit word 1 transmit shift reg start bit bit 0 bit 1 bit 7/8 write to txreg word 1 brg output (shift clock) tx/ck pin txif bit (transmit buffer empty flag) trmt bit (transmit shift reg. empty flag) 1 t cy transmit shift reg. write to txreg brg output (shift clock) tx/ck pin trmt bit (transmit shift reg. empty flag) word 1 word 2 word 1 word 2 start bit stop bit start bit transmit shift reg. word 1 word 2 bit 0 bit 1 bit 7/8 bit 0 note: this timing diagram shows two consecutive transmissions. 1 t cy 1 t cy txif bit (transmit buffer empty flag)
? 2007 microchip technology inc. ds41250f-page 125 pic16f913/914/916/917/946 table 9-1: registers associated with asynchronous transmission namebit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 0000 0000 sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txreg ausart transmit data register 0000 0000 0000 0000 txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for asynchronous transmission.
pic16f913/914/916/917/946 ds41250f-page 126 ? 2007 microchip technology inc. 9.1.2 ausart asynchronous receiver the asynchronous mode is typically used in rs-232 systems. the receiver block diagram is shown in figure 9-2. the data is received on the rx/dt pin and drives the data recovery block. the data recovery block is actually a high-speed shifter operating at 16 times the baud rate, whereas the serial receive shift register (rsr) operates at the bit rate. when all 8 or 9 bits of the character have been shifted in, they are immediately transferred to a two character first-in first-out (fifo) memory. the fifo buffering allows reception of two complete characters and the start of a third character before software must start servicing the ausart receiver. the fifo and rsr registers are not directly accessible by software. access to the received data is via the rcreg register. 9.1.2.1 enabling the receiver the ausart receiver is enabled for asynchronous operation by configuring the following three control bits: ? cren = 1 ? sync = 0 ? spen = 1 all other ausart control bits are assumed to be in their default state. setting the cren bit of the rcsta register enables the receiver circuitry of the ausart. clearing the sync bit of the txsta register configures the ausart for asynchronous operation. setting the spen bit of the rcsta register enables the ausart and automatically configures the rx/dt i/o pin as an input. the lcd seg8 function must be disabled by clearing the se8 bit of the lcdse1 register, if the rx/dt pin is shared with the lcd peripheral. 9.1.2.2 receiving data the receiver data recovery circuit initiates character reception on the falling edge of the first bit. the first bit, also known as the start bit, is always a zero. the data recovery circuit counts one-half bit time to the center of the start bit and verifies that the bit is still a zero. if it is not a zero then the data recovery circuit aborts character reception, without generating an error, and resumes looking for the falling edge of the start bit. if the start bit zero verification succeeds then the data recovery circuit counts a full bit time to the center of the next bit. the bit is then sampled by a majority detect circuit and the resulting ? 0 ? or ? 1 ? is shifted into the rsr. this repeats until all data bits have been sampled and shifted into the rsr. one final bit time is measured and the level sampled. this is the stop bit, which is always a ? 1 ?. if the data recovery circuit samples a ? 0 ? in the stop bit position then a framing error is set for this character, otherwise the framing error is cleared for this character. see section 9.1.2.4 ?receive framing error? for more information on framing errors. immediately after all data bits and the stop bit have been received, the character in the rsr is transferred to the ausart receive fifo and the rcif interrupt flag bit of the pir1 register is set. the top character in the fifo is transferred out of the fifo by reading the rcreg register. 9.1.2.3 receive interrupts the rcif interrupt flag bit of the pir1 register is set whenever the ausart receiver is enabled and there is an unread character in the receive fifo. the rcif interrupt flag bit is read-only, it cannot be set or cleared by software. rcif interrupts are enabled by setting all of the following bits: ? rcie interrupt enable bit of the pie1 register ? peie peripheral interrupt enable bit of the intcon register ? gie global interrupt enable bit of the intcon register the rcif interrupt flag bit of the pir1 register will be set when there is an unread character in the fifo, regardless of the state of interrupt enable bits. note: when the spen bit is set the tx/ck i/o pin is automatically configured as an output, regardless of the state of the corresponding tris bit and whether or not the ausart transmitter is enabled. the port latch is disconnected from the output driver so it is not possible to use the tx/ck pin as a general purpose output. note: if the receive fifo is overrun, no additional characters will be received until the overrun condition is cleared. see section 9.1.2.5 ?receive overrun error? for more information on overrun errors.
? 2007 microchip technology inc. ds41250f-page 127 pic16f913/914/916/917/946 9.1.2.4 receive framing error each character in the receive fifo buffer has a corresponding framing error status bit. a framing error indicates that a stop bit was not seen at the expected time. the framing error status is accessed via the ferr bit of the rcsta register. the ferr bit represents the status of the top unread character in the receive fifo. therefore, the ferr bit must be read before reading the rcreg. the ferr bit is read-only and only applies to the top unread character in the receive fifo. a framing error (ferr = 1 ) does not preclude reception of additional characters. it is not necessary to clear the ferr bit. reading the next character from the fifo buffer will advance the fifo to the next character and the next corresponding framing error. the ferr bit can be forced clear by clearing the spen bit of the rcsta register which resets the ausart. clearing the cren bit of the rcsta register does not affect the ferr bit. a framing error by itself does not generate an interrupt. 9.1.2.5 receive overrun error the receive fifo buffer can hold two characters. an overrun error will be generated if a third character, in its entirety, is received before the fifo is accessed. when this happens the oerr bit of the rcsta register is set. the characters already in the fifo buffer can be read but no additional characters will be received until the error is cleared. the error must be cleared by either clearing the cren bit of the rcsta register. 9.1.2.6 receiving 9-bit characters the ausart supports 9-bit character reception. when the rx9 bit of the rcsta register is set the ausart will shift 9 bits into the rsr for each character received. the rx9d bit of the rcsta register is the ninth and most significant data bit of the top unread character in the receive fifo. when reading 9-bit data from the receive fifo buffer, the rx9d data bit must be read before reading the 8 least significant bits from the rcreg. 9.1.2.7 address detection a special address detection mode is available for use when multiple receivers share the same transmission line, such as in rs-485 systems. address detection is enabled by setting the adden bit of the rcsta register. address detection requires 9-bit character reception. when address detection is enabled, only characters with the ninth data bit set will be transferred to the receive fifo buffer, thereby setting the rcif interrupt bit of the pir1 register. all other characters will be ignored. upon receiving an address character, user software determines if the address matches its own. upon address match, user software must disable address detection by clearing the adden bit before the next stop bit occurs. when user software detects the end of the message, determined by the message protocol used, software places the receiver back into the address detection mode by setting the adden bit. note: if all receive characters in the receive fifo have framing errors, repeated reads of the rcreg will not clear the ferr bit.
pic16f913/914/916/917/946 ds41250f-page 128 ? 2007 microchip technology inc. 9.1.2.8 asynchronous reception set-up: 1. initialize the spbrg register and the brgh bit to achieve the desired baud rate (see section 9.2 ?ausart baud rate generator (brg)? ). 2. enable the serial port by setting the spen bit. the sync bit must be clear for asynchronous operation. 3. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 4. if 9-bit reception is desired, set the rx9 bit. 5. enable reception by setting the cren bit. 6. the rcif interrupt flag bit of the pir1 register will be set when a character is transferred from the rsr to the receive buffer. an interrupt will be generated if the rcie bit of the pie1 register was also set. 7. read the rcsta register to get the error flags and, if 9-bit data reception is enabled, the ninth data bit. 8. get the received 8 least significant data bits from the receive buffer by reading the rcreg register. 9. if an overrun occurred, clear the oerr flag by clearing the cren receiver enable bit. 9.1.2.9 9-bit address detection mode set-up this mode would typically be used in rs-485 systems. to set up an asynchronous reception with address detect enable: 1. initialize the spbrg register and the brgh bit to achieve the desired baud rate (see section 9.2 ?ausart baud rate generator (brg)? ). 2. enable the serial port by setting the spen bit. the sync bit must be clear for asynchronous operation. 3. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 4. enable 9-bit reception by setting the rx9 bit. 5. enable address detection by setting the adden bit. 6. enable reception by setting the cren bit. 7. the rcif interrupt flag bit of the pir1 register will be set when a character with the ninth bit set is transferred from the rsr to the receive buffer. an interrupt will be generated if the rcie inter- rupt enable bit of the pie1 register was also set. 8. read the rcsta register to get the error flags. the ninth data bit will always be set. 9. get the received 8 least significant data bits from the receive buffer by reading the rcreg register. software determines if this is the device?s address. 10. if an overrun occurred, clear the oerr flag by clearing the cren receiver enable bit. 11. if the device has been addressed, clear the adden bit to allow all received data into the receive buffer and generate interrupts. figure 9-5: asynchronous reception start bit bit 7/8 bit 1 bit 0 bit 7/8 bit 0 stop bit start bit start bit bit 7/8 stop bit rx/dt pin reg rcv buffer reg rcv shift read rcv buffer reg rcreg rcif (interrupt flag) oerr bit cren word 1 rcreg word 2 rcreg stop bit note: this timing diagram shows three words appearing on the rx input. the rcreg (receive buffer) is read after the third word, causing the oerr (overrun) bit to be set.
? 2007 microchip technology inc. ds41250f-page 129 pic16f913/914/916/917/946 table 9-2: registers associated with asynchronous reception namebit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcreg ausart receive data register 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 0000 0000 sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txsta csrc tx9 txen sync ?brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for asynchronous reception.
pic16f913/914/916/917/946 ds41250f-page 130 ? 2007 microchip technology inc. register 9-1: txsta: transmit status and control register r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r-1 r/w-0 csrc tx9 txen (1) sync ? brgh trmt tx9d bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 csrc: clock source select bit asynchronous mode : don?t care synchronous mode : 1 = master mode (clock generated internally from brg) 0 = slave mode (clock from external source) bit 6 tx9: 9-bit transmit enable bit 1 = selects 9-bit transmission 0 = selects 8-bit transmission bit 5 txen: transmit enable bit (1) 1 = transmit enabled 0 = transmit disabled bit 4 sync: ausart mode select bit 1 = synchronous mode 0 = asynchronous mode bit 3 unimplemented: read as ? 0 ? bit 2 brgh: high baud rate select bit asynchronous mode : 1 = high speed 0 = low speed synchronous mode: unused in this mode bit 1 trmt: transmit shift register status bit 1 = tsr empty 0 = tsr full bit 0 tx9d: ninth bit of transmit data can be address/data bit or a parity bit. note 1: sren/cren overrides txen in sync mode.
? 2007 microchip technology inc. ds41250f-page 131 pic16f913/914/916/917/946 register 9-2: rcsta: receive status and control register (1) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r-0 r-0 r-x spen rx9 sren cren adden ferr oerr rx9d bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 spen: serial port enable bit 1 = serial port enabled (configures rx/dt and tx/ck pins as serial port pins) 0 = serial port disabled (held in reset) bit 6 rx9: 9-bit receive enable bit 1 = selects 9-bit reception 0 = selects 8-bit reception bit 5 sren: single receive enable bit asynchronous mode : don?t care synchronous mode ? master : 1 = enables single receive 0 = disables single receive this bit is cleared after reception is complete. synchronous mode ? slave don?t care bit 4 cren: continuous receive enable bit asynchronous mode : 1 = enables receiver 0 = disables receiver synchronous mode : 1 = enables continuous receive until enable bit cren is cleared (cren overrides sren) 0 = disables continuous receive bit 3 adden: address detect enable bit asynchronous mode 9-bit (rx9 = 1 ) : 1 = enables address detection, enable interrupt and load the receive buffer when rsr<8> is set 0 = disables address detection, all bytes are received and ninth bit can be used as parity bit asynchronous mode 8-bit (rx9 = 0 ) : don?t care synchronous mode : must be set to ? 0 ? bit 2 ferr: framing error bit 1 = framing error (can be updated by reading rcreg register and receive next valid byte) 0 = no framing error bit 1 oerr: overrun error bit 1 = overrun error (can be cleared by clearing bit cren) 0 = no overrun error bit 0 rx9d: ninth bit of received data this can be address/data bit or a parity bit and must be calculated by user firmware.
pic16f913/914/916/917/946 ds41250f-page 132 ? 2007 microchip technology inc. 9.2 ausart baud rate generator (brg) the baud rate generator (brg) is an 8-bit timer that is dedicated to the support of both the asynchronous and synchronous ausart operation. the spbrg register determines the period of the free running baud rate timer. in asynchronous mode the multiplier of the baud rate period is determined by the brgh bit of the txsta register. in synchronous mode, the brgh bit is ignored. table 9-3 contains the formulas for determining the baud rate. example 9-1 provides a sample calculation for determining the baud rate and baud rate error. typical baud rates and error values for various asynchronous modes have been computed for your convenience and are shown in table 9-3. it may be advantageous to use the high baud rate (brgh = 1 ), to reduce the baud rate error. writing a new value to the spbrg register causes the brg timer to be reset (or cleared). this ensures that the brg does not wait for a timer overflow before out- putting the new baud rate. example 9-1: calculating baud rate error table 9-3: baud rate formulas table 9-4: registers associated with the baud rate generator for a device with f osc of 16 mhz, desired baud rate of 9600, asynchronous mode: solving for spbrg: x f osc desired baud rate --------------------------------------------- 64 --------------------------------------------- 1 ? = desired baud rate f osc 64 spbrg 1 + () --------------------------------------- = 16000000 9600 ----------------------- - 64 ----------------------- -1 ? = 25.042 [] 25 == calculated baud rate 16000000 64 25 1 + () -------------------------- - = 9615 = error calc. baud rate desired baud rate ? desired baud rate -------------------------------------------------------------------------------------------- = 9615 9600 ? () 9600 ---------------------------------- 0 . 1 6 % == configuration bits ausart mode baud rate formula sync brgh 00 asynchronous f osc /[64 (n+1)] 01 asynchronous f osc /[16 (n+1)] 1x synchronous f osc /[4 (n+1)] legend: x = don?t care, n = value of spbrg register namebit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 0000 0000 txsta csrc tx9 txen sync ?brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for the baud rate generator.
? 2007 microchip technology inc. ds41250f-page 133 pic16f913/914/916/917/946 table 9-5: baud rates for asynchronous modes baud rate sync = 0 , brgh = 0 f osc = 20.000 mhz f osc = 18.432 mhz f osc = 11.0592 mhz f osc = 8.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300?? ? ?? ? ?? ? ?? ? 1200 1221 1.73 255 1200 0.00 239 1200 0.00 143 1202 0.16 103 2400 2404 0.16 129 2400 0.00 119 2400 0.00 71 2404 0.16 51 9600 9470 -1.36 32 9600 0.00 29 9600 0.00 17 9615 0.16 12 10417 10417 0.00 29 10286 -1.26 27 10165 -2.42 16 10417 0.00 11 19.2k 19.53k 1.73 15 19.20k 0.00 14 19.20k 0.00 8 ? ? ? 57.6k ? ? ? 57.60k 0.00 7 57.60k 0.00 2 ? ? ? 115.2k ? ? ? ? ? ? ? ? ? ? ? ? baud rate sync = 0 , brgh = 0 f osc = 4.000 mhz f osc = 3.6864 mhz f osc = 2.000 mhz f osc = 1.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 300 0.16 207 300 0.00 191 300 0.16 103 300 0.16 51 1200 1202 0.16 51 1200 0.00 47 1202 0.16 25 1202 0.16 12 2400 2404 0.16 25 2400 0.00 23 2404 0.16 12 ? ? ? 9600 ? ? ? 9600 0.00 5 ? ? ? ? ? ? 10417 10417 0.00 5 ? ? ? 10417 0.00 2 ? ? ? 19.2k ? ? ? 19.20k 0.00 2 ? ? ? ? ? ? 57.6k ? ? ? 57.60k 0.00 0 ? ? ? ? ? ? 115.2k ? ? ? ? ? ? ? ? ? ? ? ? baud rate sync = 0 , brgh = 1 f osc = 20.000 mhz f osc = 18.432 mhz f osc = 11.0592 mhz f osc = 8.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 ?? ? ?? ? ?? ? ?? ? 1200 ? ? ? ? ? ? ? ? ? ? ? ? 2400 ? ? ? ? ? ? ?? ? 2404 0.16 207 9600 9615 0.16 129 9600 0.00 119 9600 0.00 71 9615 0.16 51 10417 10417 0.00 119 10378 -0.37 110 10473 0.53 65 10417 0.00 47 19.2k 19.23k 0.16 64 19.20k 0.00 59 19.20k 0.00 35 19231 0.16 25 57.6k 56.82k -1.36 21 57.60k 0.00 19 57.60k 0.00 11 55556 -3.55 8 115.2k 113.64k -1.36 10 115.2k 0.00 9 115.2k 0.00 5 ? ? ?
pic16f913/914/916/917/946 ds41250f-page 134 ? 2007 microchip technology inc. baud rate sync = 0 , brgh = 1 f osc = 4.000 mhz f osc = 3.6864 mhz f osc = 2.000 mhz f osc = 1.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 ? ? ? ? ? ? ? ? ? 300 0.16 207 1200 1202 0.16 207 1200 0.00 191 1202 0.16 103 1202 0.16 51 2400 2404 0.16 103 2400 0.00 95 2404 0.16 51 2404 0.16 25 9600 9615 0.16 25 9600 0.00 23 9615 0.16 12 ? ? ? 10417 10417 0.00 23 10473 0.53 21 10417 0.00 11 10417 0.00 5 19.2k 19.23k 0.16 12 19.2k 0.00 11 ? ? ? ? ? ? 57.6k ? ? ? 57.60k 0.00 3 ? ? ? ? ? ? 115.2k ? ? ? 115.2k 0.00 1 ? ? ? ? ? ? table 9-5: baud rates for asynchronous modes
? 2007 microchip technology inc. ds41250f-page 135 pic16f913/914/916/917/946 9.3 ausart synchronous mode synchronous serial communications are typically used in systems with a single master and one or more slaves. the master device contains the necessary cir- cuitry for baud rate generation and supplies the clock for all devices in the system. slave devices can take advantage of the master clock by eliminating the inter- nal clock generation circuitry. there are two signal lines in synchronous mode: a bidi- rectional data line and a clock line. slaves use the external clock supplied by the master to shift the serial data into and out of their respective receive and trans- mit shift registers. since the data line is bidirectional, synchronous operation is half-duplex only. half-duplex refers to the fact that master and slave devices can receive and transmit data but not both simultaneously. the ausart can operate as either a master or slave device. start and stop bits are not used in synchronous transmissions. 9.3.1 synchronous master mode the following bits are used to configure the ausart for synchronous master operation: ? sync = 1 ? csrc = 1 ? sren = 0 (for transmit); sren = 1 (for receive) ? cren = 0 (for transmit); cren = 1 (for receive) ? spen = 1 setting the sync bit of the txsta register configures the device for synchronous operation. setting the csrc bit of the txsta register configures the device as a master. clearing the sren and cren bits of the rcsta register ensures that the device is in the transmit mode, otherwise the device will be configured to receive. setting the spen bit of the rcsta register enables the ausart. the lcd seg8 and seg9 functions must be disabled by clearing the se8 and se9 bits of the lcdse1 register, if the rx/dt and tx/ck pins are shared with the lcd peripheral. 9.3.1.1 master clock synchronous data transfers use a separate clock line, which is synchronous with the data. a device config- ured as a master transmits the clock on the tx/ck line. the tx/ck pin output driver is automatically enabled when the ausart is configured for synchronous transmit or receive operation. serial data bits change on the leading edge to ensure they are valid at the trail- ing edge of each clock. one clock cycle is generated for each data bit. only as many clock cycles are gener- ated as there are data bits. 9.3.1.2 synchronous master transmission data is transferred out of the device on the rx/dt pin. the rx/dt and tx/ck pin output drivers are automat- ically enabled when the ausart is configured for synchronous master transmit operation. a transmission is initiated by writing a character to the txreg register. if the tsr still contains all or part of a previous character the new character data is held in the txreg until the last bit of the previous character has been transmitted. if this is the first character, or the pre- vious character has been completely flushed from the tsr, the data in the txreg is immediately transferred to the tsr. the transmission of the character com- mences immediately following the transfer of the data to the tsr from the txreg. each data bit changes on the leading edge of the master clock and remains valid until the subsequent leading clock edge. 9.3.1.3 synchronous master transmission set-up: 1. initialize the spbrg register and the brgh bit to achieve the desired baud rate (see section 9.2 ?ausart baud rate generator (brg)? ). 2. enable the synchronous master serial port by setting bits sync, spen, and csrc. 3. disable receive mode by clearing bits sren and cren. 4. enable transmit mode by setting the txen bit. 5. if 9-bit transmission is desired, set the tx9 bit. 6. if interrupts are desired, set the txie bit of the pie1 register and the gie and peie bits of the intcon register. 7. if 9-bit transmission is selected, the ninth bit should be loaded in the tx9d bit. 8. start transmission by loading data to the txreg register. note: the tsr register is not mapped in data memory, so it is not available to the user.
pic16f913/914/916/917/946 ds41250f-page 136 ? 2007 microchip technology inc. figure 9-6: synchronous t ransmission figure 9-7: synchronous transmission (through txen) table 9-6: registers associated wi th synchronous master transmission namebit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 0000 0000 sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txreg ausart transmit data register 0000 0000 0000 0000 txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for synchronous master transmission. bit 0 bit 1 bit 7 word 1 bit 2 bit 0 bit 1 bit 7 rx/dt write to txreg reg txif bit (interrupt flag) txen bit ? 1 ? ? 1 ? word 2 trmt bit write word 1 write word 2 note: sync master mode, spbrg = 0 , continuous transmission of two 8-bit words. pin tx/ck pin rx/dt pin tx/ck pin write to txreg reg txif bit trmt bit bit 0 bit 1 bit 2 bit 6 bit 7 txen bit
? 2007 microchip technology inc. ds41250f-page 137 pic16f913/914/916/917/946 9.3.1.4 synchronous master reception data is received at the rx/dt pin. the rx/dt pin output driver is automatically disabled when the ausart is configured for synchronous master receive operation. in synchronous mode, reception is enabled by setting either the single receive enable bit (sren of the rcsta register) or the continuous receive enable bit (cren of the rcsta register). when sren is set and cren is clear, only as many clock cycles are generated as there are data bits in a single character. the sren bit is automatically cleared at the completion of one character. when cren is set, clocks are continuously generated until cren is cleared. if cren is cleared in the middle of a character the ck clock stops immediately and the partial charac- ter is discarded. if sren and cren are both set, then sren is cleared at the completion of the first character and cren takes precedence. to initiate reception, set either sren or cren. data is sampled at the rx/dt pin on the trailing edge of the tx/ck clock pin and is shifted into the receive shift register (rsr). when a complete character is received into the rsr, the rcif bit of the pir1 register is set and the character is automatically transferred to the two character receive fifo. the least significant eight bits of the top character in the receive fifo are available in rcreg. the rcif bit remains set as long as there are un-read characters in the receive fifo. 9.3.1.5 slave clock synchronous data transfers use a separate clock line, which is synchronous with the data. a device configured as a slave receives the clock on the tx/ck line. the tx/ck pin output driver is automatically disabled when the device is configured for synchronous slave transmit or receive operation. serial data bits change on the leading edge to ensure they are valid at the trailing edge of each clock. one data bit is transferred for each clock cycle. only as many clock cycles should be received as there are data bits. 9.3.1.6 receive overrun error the receive fifo buffer can hold two characters. an overrun error will be generated if a third character, in its entirety, is received before rcreg is read to access the fifo. when this happens the oerr bit of the rcsta register is set. previous data in the fifo will not be overwritten. the two characters in the fifo buffer can be read, however, no additional characters will be received until the error is cleared. the oerr bit can only be cleared by clearing the overrun condition. if the overrun error occurred when the sren bit is set and cren is clear then the error is cleared by reading rcreg. if the overrun occurred when the cren bit is set then the error condition is cleared by either clearing the cren bit of the rcsta register. 9.3.1.7 receiving 9-bit characters the ausart supports 9-bit character reception. when the rx9 bit of the rcsta register is set the ausart will shift 9-bits into the rsr for each character received. the rx9d bit of the rcsta register is the ninth, and most significant, data bit of the top unread character in the receive fifo. when reading 9-bit data from the receive fifo buffer, the rx9d data bit must be read before reading the 8 least significant bits from the rcreg. address detection in synchronous modes is not supported, therefore the adden bit of the rcsta register must be cleared. 9.3.1.8 synchronous master reception set-up: 1. initialize the spbrg register for the appropriate baud rate. set or clear the brgh bit, as required, to achieve the desired baud rate. 2. enable the synchronous master serial port by setting bits sync, spen and csrc. 3. ensure bits cren and sren are clear. 4. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 5. if 9-bit reception is desired, set bit rx9. 6. verify address detection is disabled by clearing the adden bit of the rcsta register. 7. start reception by setting the sren bit or for continuous reception, set the cren bit. 8. interrupt flag bit rcif of the pir1 register will be set when reception of a character is complete. an interrupt will be generated if the rcie inter- rupt enable bit of the pie1 register was set. 9. read the rcsta register to get the ninth bit (if enabled) and determine if any error occurred during reception. 10. read the 8-bit received data by reading the rcreg register. 11. if an overrun error occurs, clear the error by either clearing the cren bit of the rcsta register or by clearing the spen bit which resets the ausart.
pic16f913/914/916/917/946 ds41250f-page 138 ? 2007 microchip technology inc. figure 9-8: synchronous reception (master mode, sren) table 9-7: registers associated wi th synchronous master reception namebit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcreg ausart receive data register 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txsta csrc tx9 txen sync ?brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for synchronous master reception. cren bit rx/dt write to bit sren sren bit rcif bit (interrupt) read rxreg ? 0 ? bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 ? 0 ? note: timing diagram demonstrates sync master mode with bit sren = 1 and bit brgh = 0 . tx/ck pin tx/ck pin pin (sckp = 0 ) (sckp = 1 )
? 2007 microchip technology inc. ds41250f-page 139 pic16f913/914/916/917/946 9.3.2 synchronous slave mode the following bits are used to configure the ausart for synchronous slave operation: ? sync = 1 ? csrc = 0 ? sren = 0 (for transmit); sren = 1 (for receive) ? cren = 0 (for transmit); cren = 1 (for receive) ? spen = 1 setting the sync bit of the txsta register configures the device for synchronous operation. clearing the csrc bit of the txsta register configures the device as a slave. clearing the sren and cren bits of the rcsta register ensures that the device is in the transmit mode, otherwise the device will be configured to receive. setting the spen bit of the rcsta register enables the ausart. the lcd seg8 and seg9 functions must be disabled by clearing the se8 and se9 bits of the lcdse1 register, if the rx/dt and tx/ck pins are shared with the lcd peripheral. 9.3.2.1 ausart synchronous slave transmit the operation of the synchronous master and slave modes are identical (see section 9.3.1.2 ?synchronous master transmission?) , except in the case of the sleep mode. if two words are written to the txreg and then the sleep instruction is executed, the following will occur: 1. the first character will immediately transfer to the tsr register and transmit. 2. the second word will remain in txreg register. 3. the txif bit will not be set. 4. after the first character has been shifted out of tsr, the txreg register will transfer the second character to the tsr and the txif bit will now be set. 5. if the peie and txie bits are set, the interrupt will wake the device from sleep and execute the next instruction. if the gie bit is also set, the program will call the interrupt service routine. 9.3.2.2 synchronous slave transmission set-up: 1. set the sync and spen bits and clear the csrc bit. 2. clear the cren and sren bits. 3. if using interrupts, ensure that the gie and peie bits of the intcon register are set and set the txie bit. 4. if 9-bit transmission is desired, set the tx9 bit. 5. enable transmission by setting the txen bit. 6. verify address detection is disabled by clearing the adden bit of the rcsta register. 7. if 9-bit transmission is selected, insert the most significant bit into the tx9d bit. 8. start transmission by writing the least significant 8 bits to the txreg register. table 9-8: registers associated wi th synchronous slave transmission namebit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txreg ausart transmit data register 0000 0000 0000 0000 txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used fo r synchronous slave transmission.
pic16f913/914/916/917/946 ds41250f-page 140 ? 2007 microchip technology inc. 9.3.2.3 ausart synchronous slave reception the operation of the synchronous master and slave modes is identical ( section 9.3.1.4 ?synchronous master reception? ), with the following exceptions: ? sleep ? cren bit is always set, therefore the receiver is never idle ? sren bit, which is a ?don't care? in slave mode a character may be received while in sleep mode by setting the cren bit prior to entering sleep. once the word is received, the rsr register will transfer the data to the rcreg register. if the rcie interrupt enable bit of the pie1 register is set, the interrupt generated will wake the device from sleep and execute the next instruction. if the gie bit is also set, the program will branch to the interrupt vector. 9.3.2.4 synchronous slave reception set-up: 1. set the sync and spen bits and clear the csrc bit. 2. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 3. if 9-bit reception is desired, set the rx9 bit. 4. verify address detection is disabled by clearing the adden bit of the rcsta register. 5. set the cren bit to enable reception. 6. the rcif bit of the pir1 register will be set when reception is complete. an interrupt will be generated if the rcie bit of the pie1 register was set. 7. if 9-bit mode is enabled, retrieve the most significant bit from the rx9d bit of the rcsta register. 8. retrieve the 8 least significant bits from the receive fifo by reading the rcreg register. 9. if an overrun error occurs, clear the error by either clearing the cren bit of the rcsta register. table 9-9: registers associated with synchronous slave reception namebit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcreg ausart receive data register 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 txsta csrc tx9 txen sync ? brgh trmt tx9d 0000 -010 0000 -010 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used fo r synchronous slave reception.
? 2007 microchip technology inc. ds41250f-page 141 pic16f913/914/916/917/946 9.4 ausart operation during sleep the ausart will remain active during sleep only in the synchronous slave mode. all other modes require the system clock and therefore cannot generate the neces- sary signals to run the transmit or receive shift regis- ters during sleep. synchronous slave mode uses an externally generated clock to run the transmit and receive shift registers. 9.4.1 synchronous receive during sleep to receive during sleep, all the following conditions must be met before entering sleep mode: ? rcsta and txsta control registers must be configured for synchronous slave reception (see section 9.3.2.4 ?synchronous slave reception set-up:? ). ? if interrupts are desired, set the rcie bit of the pie1 register and the peie bit of the intcon register. ? the rcif interrupt flag must be cleared by read- ing rcreg to unload any pending characters in the receive buffer. upon entering sleep mode, the device will be ready to accept data and clocks on the rx/dt and tx/ck pins, respectively. when the data word has been completely clocked in by the external device, the rcif interrupt flag bit of the pir1 register will be set. thereby, waking the processor from sleep. upon waking from sleep, the instruction following the sleep instruction will be executed. if the gie global interrupt enable bit of the intcon register is also set, then the interrupt service routine at address 004h will be called. 9.4.2 synchronous transmit during sleep to transmit during sleep, all the following conditions must be met before entering sleep mode: ? rcsta and txsta control registers must be configured for synchronous slave transmission (see section 9.3.2.2 ?synchronous slave transmission set-up:? ). ? the txif interrupt flag must be cleared by writing the output data to the txreg, thereby filling the tsr and transmit buffer. ? if interrupts are desired, set the txie bit of the pie1 register and the peie bit of the intcon register. upon entering sleep mode, the device will be ready to accept clocks on tx/ck pin and transmit data on the rx/dt pin. when the data word in the tsr has been completely clocked out by the external device, the pending byte in the txreg will transfer to the tsr and the txif flag will be set. thereby, waking the processor from sleep. at this point, the txreg is available to accept another character for transmission, which will clear the txif flag. upon waking from sleep, the instruction following the sleep instruction will be executed. if the gie global interrupt enable bit is also set then the interrupt service routine at address 0004h will be called.
pic16f913/914/916/917/946 ds41250f-page 142 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 143 pic16f913/914/916/917/946 10.0 liquid crystal display (lcd) driver module the liquid crystal display (lcd) driver module generates the timing control to drive a static or multiplexed lcd panel. in the pic16f913/916 devices, the module drives the panels of up to four commons and up to 16 segments. in the pic16F914/917 devices, the module drives the panels of up to four commons and up to 24 segments. in the pic16f946 device, the module drives the panels of up to four commons and up to 42 segments. the lcd module also provides control of the lcd pixel data. the lcd driver module supports: ? direct driving of lcd panel ? three lcd clock sources with selectable prescaler ? up to four commons: - static (1 common) - 1/2 multiplex (2 commons) - 1/3 multiplex (3 commons) - 1/4 multiplex (4 commons) ? segments up to: - 16 (pic16f913/916) - 24 (pic16F914/917) - 42 (pic16f946) ? static, 1/2 or 1/3 lcd bias 10.1 lcd registers the module contains the following registers: ? lcd control register (lcdcon) ? lcd phase register (lcdps) ? up to 6 lcd segment enable registers (lcdsen) ? up to 24 lcd data registers (lcddata) table 10-1: lcd segment and data registers the lcdcon register (register 10-1) controls the operation of the lcd driver module. the lcdps register (register 10-2) configures the lcd clock source prescaler and the type of waveform; type-a or type-b. the lcdse registers (register 10-3) configure the functions of the port pins. the following lcdse registers are available: ? lcdse0 se<7:0> ? lcdse1 se<15:8> ? lcdse2 se<23:16> (1) ? lcdse3 se<31:24> (2) ? lcdse4 se<39:32> (2) ? lcdse5 se<41:40> (2) once the module is initialized for the lcd panel, the individual bits of the lcddata<11:0> registers are cleared/set to represent a clear/dark pixel, respectively: ? lcddata0 seg<7:0>com0 ? lcddata1 seg<15:8>com0 ? lcddata2 seg<23:16>com0 ? lcddata3 seg<7:0>com1 ? lcddata4 seg<15:8>com1 ? lcddata5 seg<23:16>com1 ? lcddata6 seg<7:0>com2 ? lcddata7 seg<15:8>com2 ? lcddata8 seg<23:16>com2 ? lcddata9 seg<7:0>com3 ? lcddata10 seg<15:8>com3 ? lcddata11 seg<23:16>com3 the following additional registers are available on the pic16f946 only: ? lcddata12 seg<31:24>com0 ? lcddata13 seg<39:32>com0 ? lcddata14 seg<41:40>com0 ? lcddata15 seg<31:24>com1 ? lcddata16 seg<39:32>com1 ? lcddata17 seg<41:40>com1 ? lcddata18 seg<31:24>com2 ? lcddata19 seg<39:32>com2 ? lcddata20 seg<41:40>com2 ? lcddata21 seg<31:24>com3 ? lcddata22 seg<39:32>com3 ? lcddata23 seg<41:40>com3 as an example, lcddatax is detailed in register 10-4. once the module is configured, the lcden bit of the lcdcon register is used to enable or disable the lcd module. the lcd panel can also operate during sleep by clearing the slpen bit of the lcdcon register. note: com3 and seg15 share the same physical pin on the pic16f913/916, therefore seg15 is not available when using 1/4 multiplex displays. device # of lcd registers segment enable data pic16f913/916 2 8 pic16F914/917 3 12 pic16f946 6 24 note 1: pic16F914/917 and pic16f946 only. 2: pic16f946 only. note: the lcddata2, lcddata5, lcddata8 and lcddata11 registers are not implemented in the pic16f913/916 devices.
pic16f913/914/916/917/946 ds41250f-page 144 ? 2007 microchip technology inc. figure 10-1: lcd driver module block diagram data bus seg<41:0> (1, 2, 3) to i/o pads (1) lcddatax registers note 1: these are not directly connected to the i/o pads, but may be tri-stated, depending on the configuration of the lcd module. 2: seg<23:0> on pic16F914/917, seg<15:0> on pic16f913/916. 3: com3 and seg15 share the same physical pin on the pic16f913/916, therefore seg15 is not available when using 1/4 multiplex displays. com<3:0> (3) clock source timing control select and prescaler lfintosc/32 f osc /8192 t1osc/32 to i/o pads (1) lcdcon lcdps lcdsen mux
? 2007 microchip technology inc. ds41250f-page 145 pic16f913/914/916/917/946 register 10-1: lcdcon: liquid cr ystal display control register r/w-0 r/w-0 r/c-0 r/w-1 r/w-0 r/w-0 r/w-1 r/w-1 lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? c = only clearable bit ?1? = bit is set ?0? = bit is cleared x = bit is unknown -n = value at por bit 7 lcden: lcd driver enable bit 1 = lcd driver module is enabled 0 = lcd driver module is disabled bit 6 slpen : lcd driver enable in sleep mode bit 1 = lcd driver module is disabled in sleep mode 0 = lcd driver module is enabled in sleep mode bit 5 werr: lcd write failed error bit 1 = lcddatax register written while the wa bit of the lcdps register = 0 (must be cleared in software) 0 = no lcd write error bit 4 vlcden: lcd bias voltage pins enable bit 1 = vlcd pins are enabled 0 = vlcd pins are disabled bit 3-2 cs<1:0>: clock source select bits 00 = f osc /8192 01 = t1osc (timer1)/32 1x = lfintosc (31 khz)/32 bit 1-0 lmux<1:0>: commons select bits note 1: on pic16f913/916 devices, com3 and seg15 are shared on one pin, limiting the device from driving 64 pixels. lmux<1:0> multiplex maximum number of pixels bias pic16f913/916 pic16F914/917 pic16f946 00 static (com0) 16 24 42 static 01 1/2 (com<1:0>) 32 48 84 1/2 or 1/3 10 1/3 (com<2:0>) 48 72 126 1/2 or 1/3 11 1/4 (com<3:0>) 60 (1) 96 168 1/3
pic16f913/914/916/917/946 ds41250f-page 146 ? 2007 microchip technology inc. register 10-2: lcdps: lcd prescaler select register r/w-0 r/w-0 r-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 wft biasmd lcda wa lp3 lp2 lp1 lp0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 wft: waveform type select bit 1 = type-b waveform (phase changes on each frame boundary) 0 = type-a waveform (phase changes within each common interval) bit 6 biasmd: bias mode select bit when lmux<1:0> = 00 : 0 = static bias mode (do not set this bit to ? 1 ?) when lmux<1:0> = 01 : 1 = 1/2 bias mode 0 = 1/3 bias mode when lmux<1:0> = 10 : 1 = 1/2 bias mode 0 = 1/3 bias mode when lmux<1:0> = 11 : 0 = 1/3 bias mode (do not set this bit to ? 1 ?) bit 5 lcda: lcd active status bit 1 = lcd driver module is active 0 = lcd driver module is inactive bit 4 wa: lcd write allow status bit 1 = write into the lcddatax registers is allowed 0 = write into the lcddatax registers is not allowed bit 3-0 lp<3:0>: lcd prescaler select bits 1111 = 1:16 1110 = 1:15 1101 = 1:14 1100 = 1:13 1011 = 1:12 1010 = 1:11 1001 = 1:10 1000 = 1:9 0111 = 1:8 0110 = 1:7 0101 = 1:6 0100 = 1:5 0011 = 1:4 0010 = 1:3 0001 = 1:2 0000 = 1:1
? 2007 microchip technology inc. ds41250f-page 147 pic16f913/914/916/917/946 register 10-3: lcdsen: lcd segment enable registers r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 sen sen sen sen sen sen sen sen bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 sen: segment enable bits 1 = segment function of the pin is enabled 0 = i/o function of the pin is enabled register 10-4: lcddatax: lcd data registers r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x segx-comy segx-comy segx-comy segx-comy segx-comy segx-comy segx-comy segx-comy bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 segx-comy: pixel on bits 1 = pixel on (dark) 0 = pixel off (clear)
pic16f913/914/916/917/946 ds41250f-page 148 ? 2007 microchip technology inc. 10.2 lcd clock source selection the lcd driver module has 3 possible clock sources: ?f osc /8192 ?t1osc/32 ? lfintosc/32 the first clock source is the system clock divided by 8192 (f osc /8192). this divider ratio is chosen to provide about 1 khz output when the system clock is 8 mhz. the divider is not programmable. instead, the lcd prescaler bits lp<3:0> of the lcdps register are used to set the lcd frame clock rate. the second clock source is the t1osc/32. this also gives about 1 khz when a 32.768 khz crystal is used with the timer1 oscillator. to use the timer1 oscillator as a clock source, the t1oscen bit of the t1con register should be set. the third clock source is the 31 khz lfintosc/32, which provides approximately 1 khz output. the second and third clock sources may be used to continue running the lcd while the processor is in sleep. using bits cs<1:0> of the lcdcon register can select any of these clock sources. 10.2.1 lcd prescaler a 4-bit counter is available as a prescaler for the lcd clock. the prescaler is not directly readable or writable; its value is set by the lp<3:0> bits of the lcdps register, which determine the prescaler assignment and prescale ratio. the prescale values are selectable from 1:1 through 1:16. 10.3 lcd bias types the lcd driver module can be configured into one of three bias types: ? static bias (2 voltage levels: v ss and v dd ) ? 1/2 bias (3 voltage levels: v ss , 1/2 v dd and v dd ) ? 1/3 bias (4 voltage levels: v ss , 1/3 v dd , 2/3 v dd and v dd ) this module uses an external resistor ladder to generate the lcd bias voltages. the external resistor ladder should be connected to the vlcd1 pin (bias 1), vlcd2 pin (bias 2), vlcd3 pin (bias 3) and v ss . the vlcd3 pin should also be connected to v dd . figure 10-2 shows the proper way to connect the resistor ladder to the bias pins.. figure 10-2: lcd bias resist or ladder connection diagram note: vlcd pins used to supply lcd bias voltage are enabled on power-up (por) and must be disabled by the user by clearing the vlcden bit of the lcdcon register. v lcd 3 v lcd 2 v lcd 1 v lcd 0 (1) to lcd driver connections for external r-ladder 10 k * 10 k * 10 k * lcd bias 2 lcd bias 1 lcd bias 3 * these values are provided for design guidance only and should be optimized for the application by the designer. note 1: internal connection. v ss static bias 1/2 bias 1/3 bias v lcd 0v ss v ss v ss v lcd 1 ?1/2 v dd 1/3 v dd v lcd 2 ?1/2 v dd 2/3 v dd v lcd 3v dd v dd v dd 10 k *10k * v ss v dd * v dd * v dd * static bias 1/2 bias 1/3 bias
? 2007 microchip technology inc. ds41250f-page 149 pic16f913/914/916/917/946 10.4 lcd multiplex types the lcd driver module can be configured into one of four multiplex types: ? static (only com0 is used) ? 1/2 multiplex (com<1:0> are used) ? 1/3 multiplex (com<2:0> are used) ? 1/4 multiplex (com<3:0> are used) the lmux<1:0> bit setting of the lcdcon register decides the function of rb5, ra2 or either ra3 or rd0 pins (see table 10-2 for details). if the pin is a digital i/o, the corresponding tris bit controls the data direction. if the pin is a com drive, then the tris setting of that pin is overridden. table 10-2: ra3/rd0, ra2, rb5 function 10.5 segment enables the lcdsen registers are used to select the pin function for each segment pin. the selection allows each pin to operate as either an lcd segment driver or as one of the pin?s alternate functions. to configure the pin as a segment pin, the corresponding bits in the lcdsen registers must be set to ? 1 ?. if the pin is a digital i/o, the corresponding tris bit controls the data direction. any bit set in the lcdsen registers overrides any bit settings in the corresponding tris register. 10.6 pixel control the lcddatax registers contain bits which define the state of each pixel. each bit defines one unique pixel. register 10-4 shows the correlation of each bit in the lcddatax registers to the respective common and segment signals. any lcd pixel location not being used for display can be used as general purpose ram. 10.7 lcd frame frequency the rate at which the com and seg outputs change is called the lcd frame frequency. table 10-3: frame frequency formulas table 10-4: approximate frame frequency (in hz) using f osc @ 8 mhz, timer1 @ 32.768 khz or lfintosc note: on a power-on reset, the lmux<1:0> bits of the lcdcon register are ? 11 ?. multiplex lmux <1:0> ra3/rd0 (1) ra2 rb5 static 00 digital i/o digital i/o digital i/o 1/2 01 digital i/o digital i/o com1 driver 1/3 10 digital i/o com2 driver com1 driver 1/4 11 com3 driver com2 driver com1 driver note 1: ra3 for pic16f913/916, rd0 for pic16F914/917 and pic16f946 note: on a power-on reset, these pins are configured as digital i/o. multiplex frame frequency = static clock source/(4 x 1 x (lp<3:0> + 1)) 1/2 clock source/(2 x 2 x (lp<3:0> + 1)) 1/3 clock source/(1 x 3 x (lp<3:0> + 1)) 1/4 clock source/(1 x 4 x (lp<3:0> + 1)) note: clock source is f osc /8192, t1osc/32 or lfintosc/32. lp<3:0> static 1/2 1/3 1/4 2858511485 364648564 451516851 543435743 637374937 732324332
pic16f913/914/916/917/946 ds41250f-page 150 ? 2007 microchip technology inc. figure 10-3: lcd cl ock generation cs<1:0> t1osc 32 khz crystal osc. lfintosc nominal = 31 khz static 1/2 1/3, 1/4 4 lmux<1:0> 4-bit prog presc 1, 2, 3, 4 ring counter lmux<1:0> com0 com1 com2 com3 8192 f osc 2 32 32 lp<3:0> (lcdcon<3:2>) (lcdcon<1:0>) (lcdcon<1:0>) (lcdps<3:0>)
? 2007 microchip technology inc. ds41250f-page 151 pic16f913/914/916/917/946 figure 10-4: lcd segment mapping worksheet (sheet 1 of 2) lcd function com0 com1 com2 com3 pin no. port alternate functions lcddatax address lcd segment lcddatax address lcd segment lcddatax address lcd segment lcddatax address lcd segment 28-pin 40-pin 64-pin seg0 lcddata0, 0 lcddata3, 0 lcddata6, 0 lcddata9, 0 21 33 15 rb0 int seg1 lcddata0, 1 lcddata3, 1 lcddata6, 1 lcddata9, 1 22 34 16 rb1 seg2 lcddata0, 2 lcddata3, 2 lcddata6, 2 lcddata9, 2 23 35 17 rb2 seg3 lcddata0, 3 lcddata3, 3 lcddata6, 3 lcddata9, 3 24 36 18 rb3 seg4 lcddata0, 4 lcddata3, 4 lcddata6, 4 lcddata9, 4 6 6 31 ra4 c1out/t0cki seg5 lcddata0, 5 lcddata3, 5 lcddata6, 5 lcddata9, 5 7 7 32 ra5 c2out/an4/ss seg6 lcddata0, 6 lcddata3, 6 lcddata6, 6 lcddata9, 6 14 18 52 rc3 seg7 lcddata0, 7 lcddata3, 7 lcddata6, 7 lcddata9, 7 3 3 28 ra1 an1/c2- seg8 lcddata1, 0 lcddata4, 0 lcddata7, 0 lcddata10, 0 18 26 62 rc7 rx/dt/sdi/sda seg9 lcddata1, 1 lcddata4, 1 lcddata7, 1 lcddata10, 1 17 25 61 rc6 tx/ck/sck/scl seg10 lcddata1, 2 lcddata4, 2 lcddata7, 2 lcddata10, 2 16 24 60 rc5 t1cki/ccp1 seg11 lcddata1, 3 lcddata4, 3 lcddata7, 3 lcddata10, 3 15 23 59 rc4 t1g /sdo seg12 lcddata1, 4 lcddata4, 4 lcddata7, 4 lcddata10, 4 2 2 27 ra0 an0/c1- seg13 lcddata1, 5 lcddata4, 5 lcddata7, 5 lcddata10, 5 28 40 24 rb7 icspdat/icddat seg14 lcddata1, 6 lcddata4, 6 lcddata7, 6 lcddata10, 6 27 39 23 rb6 icspclk/icdck seg15 lcddata1, 7 lcddata4, 7 lcddata7, 7 lcddata10, 7 5 5 30 ra3 an3/v ref +/com3* seg16 lcddata2, 0 lcddata5, 0 lcddata8, 0 lcddata11, 0 ? 26 58 rd3 seg17 lcddata2, 1 lcddata5, 1 lcddata8, 1 lcddata11, 1 ? 27 63 rd4 seg18 lcddata2, 2 lcddata5, 2 lcddata8, 2 lcddata11, 2 ? 28 64 rd5 seg19 lcddata2, 3 lcddata5, 3 lcddata8, 3 lcddata11, 3 ? 29 1 rd6 seg20 lcddata2, 4 lcddata5, 4 lcddata8, 4 lcddata11, 4 ? 30 2 rd7 seg21 lcddata2, 5 lcddata5, 5 lcddata8, 5 lcddata11, 5 ? 8 33 re0 an5 seg22 lcddata2, 6 lcddata5, 6 lcddata8, 6 lcddata11, 6 ? 9 34 re1 an6 seg23 lcddata2, 7 lcddata5, 7 lcddata8, 7 lcddata11, 7 ? 10 35 re2 an7 pic16F914/917 and pic16f946 only. * = pic16f913/916 only.
pic16f913/914/916/917/946 ds41250f-page 152 ? 2007 microchip technology inc. figure 10-5: lcd segment mapping worksheet (sheet 2 of 2) lcd function com0 com1 com2 com3 pin no. port alternate functions lcddatax address lcd segment lcddatax address lcd segment lcddatax address lcd segment lcddatax address lcd segment 64-pin seg24 lcddata12, 0 lcddata15, 0 lcddata18, 0 lcddata21, 0 37 re4 seg25 lcddata12, 1 lcddata15, 1 lcddata18, 1 lcddata21, 1 42 re5 seg26 lcddata12, 2 lcddata15, 2 lcddata18, 2 lcddata21, 2 43 re6 seg27 lcddata12, 3 lcddata15, 3 lcddata18, 3 lcddata21, 3 44 re7 seg28 lcddata12, 4 lcddata15, 4 lcddata18, 4 lcddata21, 4 45 rf4 seg29 lcddata12, 5 lcddata15, 5 lcddata18, 5 lcddata21, 5 46 rf5 seg30 lcddata12, 6 lcddata15, 6 lcddata18, 6 lcddata21, 6 47 rf6 seg31 lcddata12, 7 lcddata15, 7 lcddata18, 7 lcddata21, 7 48 rf7 seg32 lcddata13, 0 lcddata16, 0 lcddata19, 0 lcddata22, 0 11 rf0 seg33 lcddata13, 1 lcddata16, 1 lcddata19, 1 lcddata22, 1 12 rf1 seg34 lcddata13, 2 lcddata16, 2 lcddata19, 2 lcddata22, 2 13 rf2 seg35 lcddata13, 3 lcddata16, 3 lcddata19, 3 lcddata22, 3 14 rf3 seg36 lcddata13, 4 lcddata16, 4 lcddata19, 4 lcddata22, 4 3 rg0 seg37 lcddata13, 5 lcddata16, 5 lcddata19, 5 lcddata22, 5 4 rg1 seg38 lcddata13, 6 lcddata16, 6 lcddata19, 6 lcddata22, 6 5 rg2 seg39 lcddata13, 7 lcddata16, 7 lcddata19, 7 lcddata22, 7 6 rg3 seg40 lcddata14, 0 lcddata17, 0 lcddata20, 0 lcddata23, 0 7 rg4 seg41 lcddata14, 1 lcddata17, 1 lcddata20, 1 lcddata23, 1 8 rg5 pic16f946 only.
? 2007 microchip technology inc. ds41250f-page 153 pic16f913/914/916/917/946 10.8 lcd waveform generation lcd waveforms are generated so that the net ac voltage across the dark pixel should be maximized and the net ac voltage across the clear pixel should be minimized. the net dc voltage across any pixel should be zero. the com signal represents the time slice for each common, while the seg contains the pixel data. the pixel signal (com-seg) will have no dc component and it can take only one of the two rms values. the higher rms value will create a dark pixel and a lower rms value will create a clear pixel. as the number of commons increases, the delta between the two rms values decreases. the delta represents the maximum contrast that the display can have. the lcds can be driven by two types of waveform: type-a and type-b. in type-a waveform, the phase changes within each common type, whereas in type-b waveform, the phase changes on each frame boundary. thus, type-a waveform maintains 0 v dc over a single frame, whereas type-b waveform takes two frames. figure 10-6 through figure 10-16 provide waveforms for static, half-multiplex, one-third-multiplex and quarter-multiplex drives for type-a and type-b waveforms. figure 10-6: type-a/type-b waveforms in static drive note 1: if sleep has to be executed with lcd sleep disabled (lcdcon is ? 1 ?), then care must be taken to execute sleep only when v dc on all the pixels is ? 0 ?. 2: when the lcd clock source is f osc /8192, if sleep is executed, irrespective of the lcdcon setting, the lcd goes into sleep. thus, take care to see that v dc on all pixels is ? 0 ? when sleep is executed. v 1 v 0 com0 seg0 com0-seg0 com0-seg1 seg1 v 1 v 0 v 1 v 0 v 0 v 1 -v 1 v 0 1 frame com0 seg0 seg1 seg2 seg3 seg4 seg5 seg6 seg7
pic16f913/914/916/917/946 ds41250f-page 154 ? 2007 microchip technology inc. figure 10-7: type-a waveforms in 1/2 mux, 1/2 bias drive v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 -v 2 -v 1 v 2 v 1 v 0 -v 2 -v 1 com0 com1 seg0 seg1 com0-seg0 com0-seg1 1 frame com1 com0 seg0 seg1 seg2 seg3
? 2007 microchip technology inc. ds41250f-page 155 pic16f913/914/916/917/946 figure 10-8: type-b waveforms in 1/2 mux, 1/2 bias drive v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 -v 2 -v 1 v 2 v 1 v 0 -v 2 -v 1 com0 com1 seg0 seg1 com0-seg0 com0-seg1 com1 com0 seg0 seg1 seg2 seg3 2 frames
pic16f913/914/916/917/946 ds41250f-page 156 ? 2007 microchip technology inc. figure 10-9: type-a waveforms in 1/2 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 seg0 seg1 com0-seg0 com0-seg1 1 frame com1 com0 seg0 seg1 seg2 seg3
? 2007 microchip technology inc. ds41250f-page 157 pic16f913/914/916/917/946 figure 10-10: type-b waveforms in 1/2 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 seg0 seg1 com0-seg0 com0-seg1 com1 com0 seg0 seg1 seg2 seg3 2 frames
pic16f913/914/916/917/946 ds41250f-page 158 ? 2007 microchip technology inc. figure 10-11: type-a waveforms in 1/3 mux, 1/2 bias drive v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 -v 2 -v 1 v 2 v 1 v 0 -v 2 -v 1 com0 com1 com2 seg0 seg1 com0-seg0 com0-seg1 1 frame com2 com1 com0 seg0 seg1 seg2 seg2
? 2007 microchip technology inc. ds41250f-page 159 pic16f913/914/916/917/946 figure 10-12: type-b waveforms in 1/3 mux, 1/2 bias drive v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 -v 2 -v 1 v 2 v 1 v 0 -v 2 -v 1 com0 com1 com2 seg0 seg1 com0-seg0 com0-seg1 2 frames com2 com1 com0 seg0 seg1 seg2
pic16f913/914/916/917/946 ds41250f-page 160 ? 2007 microchip technology inc. figure 10-13: type-a waveforms in 1/3 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 com2 seg0 seg1 com0-seg0 com0-seg1 1 frame com2 com1 com0 seg0 seg1 seg2 seg2
? 2007 microchip technology inc. ds41250f-page 161 pic16f913/914/916/917/946 figure 10-14: type-b waveforms in 1/3 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 com2 seg0 seg1 com0-seg0 com0-seg1 2 frames com2 com1 com0 seg0 seg1 seg2
pic16f913/914/916/917/946 ds41250f-page 162 ? 2007 microchip technology inc. figure 10-15: type-a waveforms in 1/4 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 com2 com3 seg0 seg1 com0-seg0 com0-seg1 com3 com2 com1 com0 1 frame seg0 seg1
? 2007 microchip technology inc. ds41250f-page 163 pic16f913/914/916/917/946 figure 10-16: type-b waveforms in 1/4 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 com2 com3 seg0 seg1 com0-seg0 com0-seg1 com3 com2 com1 com0 2 frames seg0 seg1
pic16f913/914/916/917/946 ds41250f-page 164 ? 2007 microchip technology inc. 10.9 lcd interrupts the lcd timing generation provides an interrupt that defines the lcd frame timing. a new frame is defined to begin at the leading edge of the com0 common signal. the interrupt will be set immediately after the lcd controller completes access- ing all pixel data required for a frame. this will occur at a fixed interval before the frame boundary (t fint ), as shown in figure 10-17. the lcd controller will begin to access data for the next frame within the interval from the interrupt to when the controller begins to access data after the interrupt (t fwr ). new data must be writ- ten within t fwr , as this is when the lcd controller will begin to access the data for the next frame. when the lcd driver is running with type-b waveforms and the lmux<1:0> bits are not equal to ? 00 ? (static drive), there are some additional issues that must be addressed. since the dc voltage on the pixel takes two frames to maintain zero volts, the pixel data must not change between subsequent frames. if the pixel data were allowed to change, the waveform for the odd frames would not necessarily be the complement of the waveform generated in the even frames and a dc component would be introduced into the panel. therefore, when using type-b waveforms, the user must synchronize the lcd pixel updates to occur within a subframe after the frame interrupt. to correctly sequence writing while in type-b, the interrupt will only occur on complete phase intervals. if the user attempts to write when the write is disabled, the werr bit of the lcdcon register is set and the write does not occur. figure 10-17: waveforms and interrupt ti ming in quarter- duty cycle drive (example ? type-b, non-static) note: the interrupt is not generated when the type-a waveform is selected and when the type-b with no multiplex (static) is selected. frame boundary frame boundary lcd interrupt occurs controller accesses next frame data t fint t fwr t fwr =t frame /2*(lmux<1:0> + 1) + t cy /2 t fint =(t fwr /2 ? (2 t cy + 40 ns)) minimum = 1.5(t frame /4) ? (2 t cy + 40 ns) (t fwr /2 ? (1 t cy + 40 ns)) maximum = 1.5(t frame /4) ? (1 t cy + 40 ns) frame boundary v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 com0 com1 com2 com3 2 frames
? 2007 microchip technology inc. ds41250f-page 165 pic16f913/914/916/917/946 10.10 operation during sleep the lcd module can operate during sleep. the selection is controlled by bit slpen of the lcdcon register. setting the slpen bit allows the lcd module to go to sleep. clearing the slpen bit allows the module to continue to operate during sleep. if a sleep instruction is executed and slpen = 1 , the lcd module will cease all functions and go into a very low-current consumption mode. the module will stop operation immediately and drive the minimum lcd voltage on both segment and common lines. figure 10-18 shows this operation. to ensure that no dc component is introduced on the panel, the sleep instruction should be executed immediately after a lcd frame boundary. for type-b multiplex (non-static), the lcd interrupt can be used to determine the frame boundary. see section 10.9 ?lcd interrupts? for the formulas to calculate the delay. in all other modes, the lcda bit can be used to determine when the display is active. to use this method, the following sequence should be used when wanting to enter into sleep mode: ? clear lcden ? wait for lcda to clear ? drive all lcd pins to inactive state using port and tris registers ? execute sleep instruction if a sleep instruction is executed and slpen = 0 , the module will continue to display the current contents of the lcddata registers. to allow the module to continue operation while in sleep, the clock source must be either the lfintosc or t1osc external oscillator. while in sleep, the lcd data cannot be changed. the lcd module current consumption will not decrease in this mode; however, the overall consumption of the device will be lower due to shut down of the core and other peripheral functions. table 10-5 shows the status of the lcd module during a sleep while using each of the three available clock sources: table 10-5: lcd module status during sleep if lcd interrupts are being generated (type-b wave- form with a multiplex mode not static) and lcdie = 1 , the device will awaken from sleep on the next frame boundary. note: when the lcden bit is cleared, the lcd module will be disabled at the completion of frame. at this time, the port pins will revert to digital functionality. to minimize power consumption due to floating digital inputs, the lcd pins should be driven low using the port and tris registers. clock source slpen operation during sleep? t1osc 0 yes 1 no lfintosc 0 yes 1 no f osc /4 0 no 1 no note: the lfintosc or external t1osc oscillator must be used to operate the lcd module during sleep.
pic16f913/914/916/917/946 ds41250f-page 166 ? 2007 microchip technology inc. figure 10-18: sleep entry/exit when slpen = 1 sleep instruction execution wake-up 2 frames v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 com0 com1 com2 seg0
? 2007 microchip technology inc. ds41250f-page 167 pic16f913/914/916/917/946 10.11 configuring the lcd module the following is the sequence of steps to configure the lcd module. 1. select the frame clock prescale using bits lp<3:0> of the lcdps register. 2. configure the appropriate pins to function as segment drivers using the lcdsen registers. 3. configure the lcd module for the following using the lcdcon register: - multiplex and bias mode, bits lmux<1:0> - timing source, bits cs<1:0> - sleep mode, bit slpen 4. write initial values to pixel data registers, lcddata0 through lcddata11 (lcddata23 on pic16f946). 5. clear lcd interrupt flag, lcdif bit of the pir2 register and if desired, enable the interrupt by setting bit lcdie of the pie2 register. 6. enable bias voltage pins (vlcd<3:1>) by setting bit vlcden of the lcdcon register. 7. enable the lcd module by setting bit lcden of the lcdcon register. 10.12 disabling the lcd module to disable the lcd module, write all ? 0 ?s to the lcdcon register. 10.13 lcd current consumption when using the lcd module the current consumption consists of the following three factors: 1. the oscillator selected 2. the lcd bias source 3. the current required to charge the lcd segments the current consumption of just the lcd module can be considered negligible compared to these other factors. the oscillator selected: for lcd operation during sleep either the t1oc or the lfintosc sources need to be used as the main system oscillator may be disabled during sleep. during sleep the lfintosc current consumption is given by electrical parameter d021, where the lfintosc use the same internal oscillator circuitry as the watchdog timer. the lcd bias source: the lcd bias source, typically an external resistor ladder which will have its own current draw. the current required to charge the lcd segments: the lcd segments which can be modeled as capaci- tors which must be both charged and discharged every frame. the size of the lcd segment and its technology determines the segment?s capacitance.
pic16f913/914/916/917/946 ds41250f-page 168 ? 2007 microchip technology inc. table 10-6: registers associated with lcd operation name bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets cmcon0 c2out c1out c2inv c1inv cis cm2 cm1 cm0 0000 0000 0000 0000 intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcddata0 seg7 com0 seg6 com0 seg5 com0 seg4 com0 seg3 com0 seg2 com0 seg1 com0 seg0 com0 xxxx xxxx uuuu uuuu lcddata1 seg15 com0 seg14 com0 seg13 com0 seg12 com0 seg11 com0 seg10 com0 seg9 com0 seg8 com0 xxxx xxxx uuuu uuuu lcddata2 (2) seg23 com0 seg22 com0 seg21 com0 seg20 com0 seg19 com0 seg18 com0 seg17 com0 seg16 com0 xxxx xxxx uuuu uuuu lcddata3 seg7 com1 seg6 com1 seg5 com1 seg4 com1 seg3 com1 seg2 com1 seg1 com1 seg0 com1 xxxx xxxx uuuu uuuu lcddata4 seg15 com1 seg14 com1 seg13 com1 seg12 com1 seg11 com1 seg10 com1 seg9 com1 seg8 com1 xxxx xxxx uuuu uuuu lcddata5 (2) seg23 com1 seg22 com1 seg21 com1 seg20 com1 seg19 com1 seg18 com1 seg17 com1 seg16 com1 xxxx xxxx uuuu uuuu lcddata6 seg7 com2 seg6 com2 seg5 com2 seg4 com2 seg3 com2 seg2 com2 seg1 com2 seg0 com2 xxxx xxxx uuuu uuuu lcddata7 seg15 com2 seg14 com2 seg13 com2 seg12 com2 seg11 com2 seg10 com2 seg9 com2 seg8 com2 xxxx xxxx uuuu uuuu lcddata8 (2) seg23 com2 seg22 com2 seg21 com2 seg20 com2 seg19 com2 seg18 com2 seg17 com2 seg16 com2 xxxx xxxx uuuu uuuu lcddata9 seg7 com3 seg6 com3 seg5 com3 seg4 com3 seg3 com3 seg2 com3 seg1 com3 seg0 com3 xxxx xxxx uuuu uuuu lcddata10 seg15 com3 seg14 com3 seg13 com3 seg12 com3 seg11 com3 seg10 com3 seg9 com3 seg8 com3 xxxx xxxx uuuu uuuu lcddata11 (2) seg23 com3 seg22 com3 seg21 com3 seg20 com3 seg19 com3 seg18 com3 seg17 com3 seg16 com3 xxxx xxxx uuuu uuuu lcddata12 (3) seg31 com0 seg30 com0 seg29 com0 seg28 com0 seg27 com0 seg26 com0 seg25 com0 seg24 com0 xxxx xxxx uuuu uuuu lcddata13 (3) seg39 com0 seg38 com0 seg37 com0 seg36 com0 seg35 com0 seg34 com0 se33 com0 seg32 com0 xxxx xxxx uuuu uuuu lcddata14 (3) ? ? ? ? ? ? seg41 com0 seg40 com0 ---- --xx ---- --uu lcddata15 (3) seg31 com1 seg30 com1 seg29 com1 seg28 com1 seg27 com1 seg26 com1 seg25 com1 seg24 com1 xxxx xxxx uuuu uuuu lcddata16 (3) seg39 com1 seg38 com1 seg37 com1 seg36 com1 seg35 com1 seg34 com1 seg33 com1 seg32 com1 xxxx xxxx uuuu uuuu lcddata17 (3) ? ? ? ? ? ? seg41 com1 seg40 com1 ---- --xx ---- --uu lcddata18 (3) seg31 com2 seg30 com2 seg29 com2 seg28 com2 seg27 com2 seg26 com2 seg25 com2 seg24 com2 xxxx xxxx uuuu uuuu lcddata19 (3) seg39 com2 seg38 com2 seg37 com2 seg36 com2 seg35 com2 seg34 com2 seg33 com2 seg32 com2 xxxx xxxx uuuu uuuu lcddata20 (3) ? ? ? ? ? ? seg41 com2 seg40 com2 ---- --xx ---- --uu lcddata21 (3) seg31 com3 seg30 com3 seg29 com3 seg28 com3 seg27 com3 seg26 com3 seg25 com3 seg24 com3 xxxx xxxx uuuu uuuu lcddata22 (3) seg39 com3 seg38 com3 seg37 com3 seg36 com3 seg35 com3 seg34 com3 seg33 com3 seg32 com3 xxxx xxxx uuuu uuuu lcddata23 (3) ? ? ? ? ? ? seg41 com3 seg40 com3 ---- --xx ---- --uu lcdps wft biasmd lcda wa lp3 lp2 lp1 lp0 0000 0000 0000 0000 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 0000 0000 uuuu uuuu lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 uuuu uuuu legend: x = unknown, u = unchanged, - = unimplemented, read as ? 0 ?. shaded cells are not used by the lcd module. note 1: these pins may be configured as port pins, depending on the oscillator mode selected. 2: pic16F914/917 and pic16f946 only. 3: pic16f946 only.
? 2007 microchip technology inc. ds41250f-page 169 pic16f913/914/916/917/946 lcdse2 (2) se23 se22 se21 se20 se19 se18 se17 se16 0000 0000 uuuu uuuu lcdse3 (3) se31 se30 se29 se28 se27 se26 se25 se24 0000 0000 0000 0000 lcdse4 (3) se39 se38 se37 se36 se35 se34 se33 se32 0000 0000 0000 0000 lcdse5 (3) ? ? ? ? ? ? se41 se40 ---- --00 ---- --00 pie2 osfie c2ie c1ie lcdie ? lvdie ? ccp2ie 0000 -0-0 0000 -0-0 pir2 osfif c2if c1if lcdif ? lvdif ? ccp2if 0000 -0-0 0000 -0-0 t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 uuuu uuuu table 10-6: registers associated with lcd operation (continued) name bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets legend: x = unknown, u = unchanged, - = unimplemented, read as ? 0 ?. shaded cells are not used by the lcd module. note 1: these pins may be configured as port pins, depending on the oscillator mode selected. 2: pic16F914/917 and pic16f946 only. 3: pic16f946 only.
pic16f913/914/916/917/946 ds41250f-page 170 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 171 pic16f913/914/916/917/946 11.0 programmable low-voltage detect (plvd) module the programmable low-voltage detect (plvd) module is a power supply detector which monitors the internal power supply. this module is typically used in key fobs and other devices, where certain actions need to be taken as a result of a falling battery voltage. the plvd module includes the following capabilities: ? eight programmable trip points ? interrupt on falling v dd ? stable reference indication ? operation during sleep a block diagram of the plvd module is shown in figure 11-1. figure 11-1: plvd block diagram figure 11-2: plvd operation lvdl<2:0> 8-to-1 8 stages lvden v dd 7 6 2 1 0 analog mux + - lvdif voltage generator det reference plvd trip point lvdif v dd set by hardware cleared by software
pic16f913/914/916/917/946 ds41250f-page 172 ? 2007 microchip technology inc. 11.1 plvd operation to setup the plvd for operation, the following steps must be taken: ? enable the module by setting the lvden bit of the lvdcon register. ? configure the trip point by setting the lvdl<2:0> bits of the lvdcon register. ? wait for the reference voltage to become stable. refer to section 11.4 ?stable reference indication? . ? clear the lvdif bit of the pir2 register. the lvdif bit will be set when v dd falls below the plvd trip point. the lvdif bit remains set until cleared by software. refer to figure 11-2. 11.2 programmable trip point the plvd trip point is selectable from one of eight voltage levels. the lvdl bits of the lvdcon register select the trip point. refer to register 11-1 for the available plvd trip points. 11.3 interrupt on falling v dd when v dd falls below the plvd trip point, the falling edge detector will set the lvdif bit. see figure 11-2. an interrupt will be generated if the following bits are also set: ? gie and peie bits of the intcon register ? lvdie bit of the pie2 register the lvdif bit must be cleared by software. an interrupt can be generated from a simulated plvd event when the lvdif bit is set by software. 11.4 stable reference indication when the plvd module is enabled, the reference volt- age must be allowed to stabilize before the plvd will provide a valid result. refer to section 19.0 ?electri- cal specifications? , table 19-13, for the stabilization time. when the hfintosc is running, the irvst bit of the lvdcon register indicates the stability of the voltage reference. the voltage reference is stable when the irvst bit is set. 11.5 operation during sleep to wake from sleep, set the lvdie bit of the pie2 register and the peie bit of the intcon register. when the lvdie and peie bits are set, the device will wake from sleep and execute the next instruction. if the gie bit is also set, the program will call the interrupt service routine upon completion of the first instruction after waking from sleep.
? 2007 microchip technology inc. ds41250f-page 173 pic16f913/914/916/917/946 table 11-1: registers associated wi th programmable low-voltage detect register 11-1: lvdcon: low-vo ltage detect control register u-0 u-0 r-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? ? irvst (1) lvden ? lvdl2 lvdl1 lvdl0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5 irvst: internal reference voltage stable status flag bit (1) 1 = indicates that the plvd is stable and plvd interrupt is reliable 0 = indicates that the plvd is not stable and plvd interrupt must not be enabled bit 4 lvden: low-voltage detect module enable bit 1 = enables plvd module, powers up plvd circuit and supporting reference circuitry 0 = disables plvd module, powers down plvd circuit and supporting reference circuitry bit 3 unimplemented: read as ? 0 ? bit 2-0 lvdl<2:0>: low-voltage detection level bits (nominal values) (3) 111 = 4.5v 110 = 4.2v 101 = 4.0v 100 = 2.3v (default) 011 = 2.2v 010 = 2.1v 001 = 2.0v (2) 000 = reserved note 1: the irvst bit is usable only when the hfintosc is running. 2: not tested and below minimum operating conditions. 3: see section 19.0 ?electrical specifications? . name bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lvdcon ? ? irvst lvden ? lvdl2 lvdl1 lvdl0 --00 -100 --00 -100 pie2 osfie c2ie c1ie lcdie ?lvdie ? ccp2ie 0000 -0-0 0000 -0-0 pir2 osfif c2if c1if lcdif ?lvdif ? ccp2if 0000 -0-0 0000 -0-0 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used by the plvd module.
pic16f913/914/916/917/946 ds41250f-page 174 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 175 pic16f913/914/916/917/946 12.0 analog-to-digital converter (adc) module the analog-to-digital converter (adc) allows conversion of an analog input signal to a 10-bit binary representation of that signal. this device uses analog inputs, which are multiplexed into a single sample and hold circuit. the output of the sample and hold is connected to the input of the converter. the converter generates a 10-bit binary result via successive approximation and stores the conversion result into the adc result registers (adresl and adresh). the adc voltage reference is software selectable to be either internally generated or externally supplied. the adc can generate an interrupt upon completion of a conversion. this interrupt can be used to wake-up the device from sleep. figure 12-1 shows the block diagram of the adc. figure 12-1: adc block diagram ra0/an0 ra1/an1 ra2/an2 ra5/an4 v dd v ref + adon go/done vcfg0 = 1 vcfg0 = 0 chs v ss re0/an5 (1) re1/an6 (1) re2/an7 (1) ra3/an3 vcfg1 = 1 vcfg1 = 0 v ref - note 1: these channels are only available on pic16F914/917 and pic16f946 devices. adresh adresl 10 10 adfm 0 = left justify 1 = right justify 000 001 010 011 100 101 110 111 adc
pic16f913/914/916/917/946 ds41250f-page 176 ? 2007 microchip technology inc. 12.1 adc configuration when configuring and using the adc the following functions must be considered: ? port configuration ? channel selection ? adc voltage reference selection ? adc conversion clock source ? interrupt control ? results formatting 12.1.1 port configuration the adc can be used to convert both analog and digital signals. when converting analog signals, the i/o pin should be configured for analog by setting the associated tris and ansel bits. see the corresponding port section for more information. 12.1.2 channel selection the chs bits of the adcon0 register determine which channel is connected to the sample and hold circuit. when changing channels, a delay is required before starting the next conversion. refer to section 12.2 ?adc operation? for more information. 12.1.3 adc v oltage reference the vcfg bits of the adcon0 register provide independent control of the positive and negative voltage references. the positive voltage reference can be either v dd or an external voltage source. likewise, the negative voltage reference can be either v ss or an external voltage source. 12.1.4 conversion clock the source of the conversion clock is software select- able via the adcs bits of the adcon1 register. there are seven possible clock options: ?f osc /2 ?f osc /4 ?f osc /8 ?f osc /16 ?f osc /32 ?f osc /64 ?f rc (dedicated internal oscillator) the time to complete one bit conversion is defined as t ad . one full 10-bit conversion requires 11 t ad periods as shown in figure 12-3. for correct conversion, the appropriate t ad specification must be met. see a/d conversion requirements in section 19.0 ?electrical specifications? for more information. table 12-1 gives examples of appropriate adc clock selections. note: analog voltages on any pin that is defined as a digital input may cause the input buffer to conduct excess current. note: unless using the f rc , any changes in the system clock frequency will change the adc clock frequency, which may adversely affect the adc result.
? 2007 microchip technology inc. ds41250f-page 177 pic16f913/914/916/917/946 table 12-1: adc clock period (t ad ) v s . device operating frequencies (vdd > 3.0v) figure 12-2: analog-to-dig ital conversion t ad cycles 12.1.5 interrupts the adc module allows for the ability to generate an interrupt upon completion of an analog-to-digital conversion. the adc interrupt flag is the adif bit in the pir1 register. the adc interrupt enable is the adie bit in the pie1 register. the adif bit must be cleared in software. this interrupt can be generated while the device is operating or while in sleep. if the device is in sleep, the interrupt will wake-up the device. upon waking from sleep, the next instruction following the sleep instruction is always executed. if the user is attempting to wake-up from sleep and resume in-line code execution, the global interrupt must be disabled. if the global interrupt is enabled, execution will switch to the interrupt service routine. please see section 12.1.5 ?interrupts? for more information. adc clock period (t ad ) device frequency (f osc ) adc clock source adcs<2:0> 20 mhz 8 mhz 4 mhz 1 mhz f osc /2 000 100 ns (2) 250 ns (2) 500 ns (2) 2.0 s f osc /4 100 200 ns (2) 500 ns (2) 1.0 s (2) 4.0 s f osc /8 001 400 ns (2) 1.0 s (2) 2.0 s 8.0 s (3) f osc /16 101 800 ns (2) 2.0 s4.0 s 16.0 s (3) f osc /32 010 1.6 s4.0 s 8.0 s (3) 32.0 s (3) f osc /64 110 3.2 s 8.0 s (3) 16.0 s (3) 64.0 s (3) f rc x11 2-6 s (1,4) 2-6 s (1,4) 2-6 s (1,4) 2-6 s (1,4) legend: shaded cells are outside of recommended range. note 1: the f rc source has a typical t ad time of 4 s for v dd > 3.0v. 2: these values violate the minimum required t ad time. 3: for faster conversion times, the selection of another clock source is recommended. 4: when the device frequency is greater than 1 mhz, the f rc clock source is only recommended if the conversion will be performed during sleep. t ad 1 t ad 2 t ad 3 t ad 4 t ad 5 t ad 6 t ad 7 t ad 8 t ad 9 set go/done bit holding capacitor is disconnected from analog input (typically 100 ns) b9 b8 b7 b6 b5 b4 b3 b2 t ad 10 t ad 11 b1 b0 t cy to t ad conversion starts adresh and adresl registers are loaded, go bit is cleared, adif bit is set, holding capacitor is connected to analog input note: the adif bit is set at the completion of every conversion, regardless of whether or not the adc interrupt is enabled.
pic16f913/914/916/917/946 ds41250f-page 178 ? 2007 microchip technology inc. 12.1.6 result formatting the 10-bit a/d conversion result can be supplied in two formats, left justified or right justified. the adfm bit of the adcon0 register controls the output format. figure 12-4 shows the two output formats. figure 12-3: 10-bit a/d conv ersion result format 12.2 adc operation 12.2.1 starting a conversion to enable the adc module, the adon bit of the adcon0 register must be set to a ? 1 ?. setting the go/done bit of the adcon0 register to a ? 1 ? will start the analog-to-digital conversion. 12.2.2 completion of a conversion when the conversion is complete, the adc module will: ? clear the go/done bit ? set the adif flag bit ? update the adresh:adresl registers with new conversion result 12.2.3 terminating a conversion if a conversion must be terminated before completion, the go/done bit can be cleared in software. the adresh:adresl registers will not be updated with the partially complete analog-to-digital conversion sample. instead, the adresh:adresl register pair will retain the value of the previous conversion. additionally, a 2t ad delay is required before another acquisition can be initiated. following this delay, an input acquisition is automatically started on the selected channel. 12.2.4 adc operation during sleep the adc module can operate during sleep. this requires the adc clock source to be set to the f rc option. when the f rc clock source is selected, the adc waits one additional instruction before starting the conversion. this allows the sleep instruction to be executed, which can reduce system noise during the conversion. if the adc interrupt is enabled, the device will wake-up from sleep when the conversion completes. if the adc interrupt is disabled, the adc module is turned off after the conversion completes, although the adon bit remains set. when the adc clock source is something other than f rc , a sleep instruction causes the present conver- sion to be aborted and the adc module is turned off, although the adon bit remains set. 12.2.5 special event trigger the ccp special event trigger allows periodic adc measurements without software intervention. when this trigger occurs, the go/done bit is set by hardware and the timer1 counter resets to zero. using the special event trigger does not assure proper adc timing. it is the user?s responsibility to ensure that the adc timing requirements are met. see section 15.0 ?capture/compare/pwm (ccp) module? for more information. adresh adresl (adfm = 0 )msb lsb bit 7 bit 0 bit 7 bit 0 10-bit a/d result unimplemented: read as ? 0 ? (adfm = 1 ) msb lsb bit 7 bit 0 bit 7 bit 0 unimplemented: read as ? 0 ? 10-bit a/d result note: the go/done bit should not be set in the same instruction that turns on the adc. refer to section 12.2.6 ?a/d conver- sion procedure? . note: a device reset forces all registers to their reset state. thus, the adc module is turned off and any pending conversion is terminated.
? 2007 microchip technology inc. ds41250f-page 179 pic16f913/914/916/917/946 12.2.6 a/d conversion procedure this is an example procedure for using the adc to perform an analog-to-digital conversion: 1. configure port: ? disable pin output driver (see tris register) ? configure pin as analog 2. configure the adc module: ? select adc conversion clock ? configure voltage reference ? select adc input channel ? select result format ? turn on adc module 3. configure adc interrupt (optional): ? clear adc interrupt flag ? enable adc interrupt ? enable peripheral interrupt ? enable global interrupt (1) 4. wait the required acquisition time (2) . 5. start conversion by setting the go/done bit. 6. wait for adc conversion to complete by one of the following: ? polling the go/done bit ? waiting for the adc interrupt (interrupts enabled) 7. read adc result 8. clear the adc interrupt flag (required if interrupt is enabled). example 12-1: a/d conversion 12.2.7 adc register definitions the following registers are used to control the opera- tion of the adc. note 1: the global interrupt can be disabled if the user is attempting to wake-up from sleep and resume in-line code execution. 2: see section 12.3 ?a/d acquisition requirements? . ;this code block configures the adc ;for polling, vdd reference, frc clock ;and an0 input. ; ;conversion start & polling for completion ; are included. ; banksel adcon1 ; movlw b?01110000? ;adc frc clock movwf adcon1 ; banksel trisa ; bsf trisa,0 ;set ra0 to input banksel ansel ; bsf ansel,0 ;set ra0 to analog banksel adcon0 ; movlw b?10000001? ;right justify, movwf adcon0 ;vdd vref, an0, on call sampletime ;acquisiton delay bsf adcon0,go ;start conversion btfsc adcon0,go ;is conversion done? goto $-1 ;no, test again banksel adresh ; movf adresh,w ;read upper 2 bits movwf resulthi ;store in gpr space banksel adresl ; movf adresl,w ;read lower 8 bits movwf resultlo ;store in gpr space
pic16f913/914/916/917/946 ds41250f-page 180 ? 2007 microchip technology inc. register 12-1: adcon0: a/ d control register 0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 adfm vcfg1 vcfg0 chs2 chs1 chs0 go/done adon bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 adfm: a/d conversion result format select bit 1 = right justified 0 = left justified bit 6 vcfg1: voltage reference bit 1 = v ref - pin 0 = v ss bit 5 vcfg0: voltage reference bit 1 = v ref + pin 0 = v ss bit 4-2 chs<2:0>: analog channel select bits 000 = an0 001 = an1 010 = an2 011 = an3 100 = an4 101 = an5 (1) 110 = an6 (1) 111 = an7 (1) bit 1 go/done : a/d conversion status bit 1 = a/d conversion cycle in progress. setting this bit starts an a/d conversion cycle. this bit is automatically cleared by hardware when the a/d conversion has completed. 0 = a/d conversion completed/not in progress bit 0 adon: adc enable bit 1 = adc is enabled 0 = adc is disabled and consumes no operating current note 1: not available on 28-pin devices.
? 2007 microchip technology inc. ds41250f-page 181 pic16f913/914/916/917/946 register 12-2: adcon1: a/ d control register 1 u-0 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 u-0 ? adcs2 adcs1 adcs0 ? ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 unimplemented: read as ? 0 ? bit 6-4 adcs<2:0>: a/d conversion clock select bits 000 = f osc /2 001 = f osc /8 010 = f osc /32 x11 = f rc (clock derived from a dedicated internal oscillator = 500 khz max.) 100 = f osc /4 101 = f osc /16 110 = f osc /64 bit 3-0 unimplemented: read as ? 0 ?
pic16f913/914/916/917/946 ds41250f-page 182 ? 2007 microchip technology inc. register 12-3: adresh: adc result register high (adresh) adfm = 0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x adres9 adres8 adres7 adres6 adres5 adres4 adres3 adres2 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 adres<9:2> : adc result register bits upper 8 bits of 10-bit conversion result register 12-4: adresl: adc result register low (adresl) adfm = 0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x adres1 adres0 ? ? ? ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 adres<1:0> : adc result register bits lower 2 bits of 10-bit conversion result bit 5-0 reserved : do not use. register 12-5: adresh: adc result register high (adresh) adfm = 1 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x ? ? ? ? ? ? adres9 adres8 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-2 reserved : do not use. bit 1-0 adres<9:8> : adc result register bits upper 2 bits of 10-bit conversion result register 12-6: adresl: adc result register low (adresl) adfm = 1 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x adres7 adres6 adres5 adres4 adres3 adres2 adres1 adres0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 adres<7:0> : adc result register bits lower 8 bits of 10-bit conversion result
? 2007 microchip technology inc. ds41250f-page 183 pic16f913/914/916/917/946 12.3 a/d acquisition requirements for the adc to meet its specified accuracy, the charge holding capacitor (c hold ) must be allowed to fully charge to the input channel voltage level. the analog input model is shown in figure 12-4. the source impedance (r s ) and the internal sampling switch (r ss ) impedance directly affect the time required to charge the capacitor c hold . the sampling switch (r ss ) impedance varies over the device voltage (v dd ), see figure 12-4. the maximum recommended impedance for analog sources is 10 k . as the source impedance is decreased, the acquisition time may be decreased. after the analog input channel is selected (or changed), an a/d acquisition must be done before the conversion can be started. to calculate the minimum acquisition time, equation 12-1 may be used. this equation assumes that 1/2 lsb error is used (1024 steps for the adc). the 1/2 lsb error is the maximum error allowed for the adc to meet its specified resolution. equation 12-1: acquisition time example t acq amplifier settling time hold capacitor charging time temperature coefficient ++ = t amp t c t coff ++ = 2 st c temperature - 25c () 0.05 s/c () [] ++ = t c c hold r ic r ss r s ++ () ln(1/2047) ? = 10pf 1k 7k 10k ++ () ? ln(0.0004885) = 1.37 = s t acq 2 s 1.37 s 50c- 25c () 0.05 s /c () [] ++ = 4.67 s = v applied 1e tc ? rc --------- ? ?? ?? ?? v applied 1 1 2 n1 + () 1 ? -------------------------- ? ?? ?? = v applied 1 1 2 n1 + () 1 ? -------------------------- ? ?? ?? v chold = v applied 1e t c ? rc --------- - ? ?? ?? ?? v chold = ;[1] v chold charged to within 1/2 lsb ;[2] v chold charge response to v applied ;combining [1] and [2] the value for t c can be approximated with the following equations: solving for t c : therefore: temperature 50c and external impedance of 10k 5.0v v dd = assumptions: note: where n = number of bits of the adc. note 1: the reference voltage (v ref ) has no effect on the equation, since it cancels itself out. 2: the charge holding capacitor (c hold ) is not discharged after each conversion. 3: the maximum recommended impedance for analog sources is 10 k . this is required to meet the pin leakage specification.
pic16f913/914/916/917/946 ds41250f-page 184 ? 2007 microchip technology inc. figure 12-4: analog input model figure 12-5: adc transfer function c pin va rs anx 5 pf v dd v t = 0.6v v t = 0.6v i leakage (1) r ic 1k sampling switch ss rss c hold = 10 pf v ss /v ref - 6v sampling switch 5v 4v 3v 2v 567891011 (k ) v dd legend: c pin v t i leakage r ic ss c hold = input capacitance = threshold voltage = leakage current at the pin due to = interconnect resistance = sampling switch = sample/hold capacitance various junctions r ss note 1: see section 19.0 ?electrical specifications? . 3ffh 3feh adc output code 3fdh 3fch 004h 003h 002h 001h 000h full-scale 3fbh 1 lsb ideal v ss /v ref - zero-scale transition v dd /v ref + transition 1 lsb ideal full-scale range analog input voltage
? 2007 microchip technology inc. ds41250f-page 185 pic16f913/914/916/917/946 table 12-2: summary of associated adc registers name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets adcon0 adfm vcfg1 vcfg0 chs2 chs1 chs0 go/done adon 0000 0000 0000 0000 adcon1 ? adcs2 adcs1 adcs0 ? ? ? ? -000 ---- -000 ---- ansel ans7 ans6 ans5 ans4 ans3 ans2 ans1 ans0 1111 1111 1111 1111 adresh a/d result register high byte xxxx xxxx uuuu uuuu adresl a/d result register low byte xxxx xxxx uuuu uuuu intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 0000 0000 0000 0000 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 lcdse2 (1) se23 se22 se21 se20 se19 se18 se17 se16 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 porta ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 xxxx xxxx uuuu uuuu portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx xxxx uuuu uuuu porte re7 re6 re5 re4 re3 re2 re1 re0 xxxx xxxx uuuu uuuu trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 1111 ---- 1111 ---- trise trise7 trise6 trise5 trise4 trise3 trise2 trise1 trise0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, ? = unimplemented read as ? 0 ?. shaded cells are not used for adc module.
pic16f913/914/916/917/946 ds41250f-page 186 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 187 pic16f913/914/916/917/946 13.0 data eeprom and flash program memory control data eeprom memory is readable and writable and the flash program memory is readable during normal operation (full v dd range). these memories are not directly mapped in the register file space. instead, they are indirectly addressed through the special function registers. there are six sfrs used to access these memories: ? eecon1 ? eecon2 ? eedatl ? eedath ? eeadrl ? eeadrh when interfacing the data memory block, eedatl holds the 8-bit data for read/write, and eeadrl holds the address of the ee data location being accessed. this device has 256 bytes of data eeprom with an address range from 00h to ffh. when interfacing the program memory block, the eedatl and eedath registers form a 2-byte word that holds the 14-bit data for read, and the eeadrl and eeadrh registers form a 2-byte word that holds the 13-bit address of the eeprom location being accessed. this family of devices has 4k and 8k words of program flash with an address range from 0h-0fffh and 0h-1fffh. the program memory allows one word reads. the eeprom data memory allows byte read and write. a byte write automatically erases the location and writes the new data (erase before write). the write time is controlled by an on-chip timer. the write/erase voltages are generated by an on-chip charge pump rated to operate over the voltage range of the device for byte or word operations. when the device is code-protected, the cpu may continue to read and write the data eeprom memory and read the program memory. when code-protected, the device programmer can no longer access data or program memory. 13.1 eeadrl and eeadrh registers the eeadrl and eeadrh registers can address up to a maximum of 256 bytes of data eeprom or up to a maximum of 8k words of program flash. when selecting a program address value, the msb of the address is written to the eeadrh register and the lsb is written to the eeadrl register. when selecting a data address value, only the lsb of the address is written to the eeadrl register. 13.1.1 eecon1 and eecon2 registers eecon1 is the control register for ee memory accesses. control bit eepgd determines if the access will be a program or data memory access. when clear, as it is when reset, any subsequent operations will operate on the data memory. when set, any subsequent operations will operate on the program memory. program memory can only be read. control bits rd and wr initiate read and write, respectively. these bits cannot be cleared, only set, in software. they are cleared in hardware at completion of the read or write operation. the inability to clear the wr bit in software prevents the accidental, premature termination of a write operation. the wren bit, when set, will allow a write operation to data eeprom. on power-up, the wren bit is clear. the wrerr bit is set when a write operation is inter- rupted by a mclr or a wdt time-out reset during normal operation. in these situations, following reset, the user can check the wrerr bit. the data and address registers will be cleared on the reset. user code can then run an appropriate recovery routine. interrupt flag bit eeif of the pir1 register is set when write is complete. it must be cleared in the software. eecon2 is not a physical register. reading eecon2 will read all ? 0 ?s. the eecon2 register is used exclusively in the data eeprom write sequence.
pic16f913/914/916/917/946 ds41250f-page 188 ? 2007 microchip technology inc. register 13-1: eedatl: eeprom/prog ram memory data low byte register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 eedatl7 eedatl6 eedatl5 eedatl4 eedatl3 eedatl2 eedatl1 eedatl0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 eedatl<7:0> : byte value to write to or read from data eeprom bits or to read from program memory register 13-2: eeadrl: eeprom/program memory address low byte register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 eeadrl7 eeadrl6 eeadrl5 eeadrl4 eeadrl3 eeadrl2 eeadrl1 eeadrl0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-0 eeadrl<7:0> : specifies one of 256 locations for eeprom read/write operation bits or low address byte for program memory reads register 13-3: eedath: program memory data high byte register u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? eedath5 eedath4 eedath3 eedath2 eedath1 eedath0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5-0 eedath<5:0> : byte value to read from program memory register 13-4: eeadrh: program memory address high byte register u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? ? eedath4 eedath3 eedath2 eedath1 eedath0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-5 unimplemented: read as ? 0 ? bit 4-0 eeadrh<4:0> : specifies the high address byte for program memory reads
? 2007 microchip technology inc. ds41250f-page 189 pic16f913/914/916/917/946 register 13-5: eecon1: ee prom control register r/w-x u-0 u-0 u-0 r/w-x r/w-0 r/s-0 r/s-0 eepgd ? ? ? wrerr wren wr rd bit 7 bit 0 legend: s = bit can only be set r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 eepgd: program/data eeprom select bit 1 = accesses program memory 0 = accesses data memory bit 6-4 unimplemented: read as ? 0 ? bit 3 wrerr: eeprom error flag bit 1 = a write operation is prematurely terminated (any mclr reset, any wdt reset during normal operation or bor reset) 0 = the write operation completed bit 2 wren: eeprom write enable bit 1 = allows write cycles 0 = inhibits write to the data eeprom bit 1 wr : write control bit eepgd = 1 : this bit is ignored eepgd = 0 : 1 = initiates a write cycle (the bit is cleared by hardware once write is complete. the wr bit can only be set, not cleared, in software.) 0 = write cycle to the data eeprom is complete bit 0 rd: read control bit 1 = initiates a memory read (the rd is cleared in hardware and can only be set, not cleared, in software.) 0 = does not initiate a memory read
pic16f913/914/916/917/946 ds41250f-page 190 ? 2007 microchip technology inc. 13.1.2 reading the data eeprom memory to read a data memory location, the user must write the address to the eeadrl register, clear the eepgd control bit, and then set control bit rd of the eecon1 register. the data is available in the very next cycle, in the eedatl register; therefore, it can be read in the next instruction. eedatl will hold this value until another read or until it is written to by the user (during a write operation). example 13-1: data eeprom read 13.1.3 writing to the data eeprom memory to write an eeprom data location, the user must first write the address to the eeadrl register and the data to the eedatl register. then the user must follow a specific sequence to initiate the write for each byte. the write will not initiate if the sequence described below is not followed exactly (write 55h to eecon2, write aah to eecon2, then set wr bit) for each byte. interrupts should be disabled during this code segment. additionally, the wren bit in eecon1 must be set to enable write. this mechanism prevents accidental writes to data eeprom due to errant (unexpected) code execution (i.e., lost programs). the user should keep the wren bit clear at all times, except when updating eeprom. the wren bit is not cleared by hardware. after a write sequence has been initiated, clearing the wren bit will not affect this write cycle. the wr bit will be inhibited from being set unless the wren bit is set. at the completion of the write cycle, the wr bit is cleared in hardware and the ee write complete interrupt flag bit (eeif) is set. the user can either enable this interrupt or poll this bit. eeif must be cleared by software. the steps to write to eeprom data memory are: 1. if step 10 is not implemented, check the wr bit to see if a write is in progress. 2. write the address to eeadrl. make sure that the address is not larger than the memory size of the device. 3. write the 8-bit data value to be programmed in the eedatl register. 4. clear the eepgd bit to point to eeprom data memory. 5. set the wren bit to enable program operations. 6. disable interrupts (if enabled). 7. execute the special five instruction sequence: ? write 55h to eecon2 in two steps (first to w, then to eecon2) ? write aah to eecon2 in two steps (first to w, then to eecon2) ? set the wr bit 8. enable interrupts (if using interrupts). 9. clear the wren bit to disable program operations. 10. at the completion of the write cycle, the wr bit is cleared and the eeif interrupt flag bit is set. (eeif must be cleared by firmware.) if step 1 is not implemented, then firmware should check for eeif to be set, or wr to clear, to indicate the end of the program cycle. example 13-2: data eeprom write banksel eeadrl ; movf data_ee_addr,w ;data memory movwf eeadrl ;address to read banksel eecon1 ; bcf eecon1,eepgd ;point to data ;memory bsf eecon1,rd ;ee read banksel eedatl ; movf eedatl,w ;w = eeprom data banksel eecon1 ; btfsc eecon1,wr ;wait for write goto $-1 ;to complete banksel eeadrl ; movf data_ee_addr,w ;data memory movwf eeadrl ;address to write movf data_ee_data,w ;data memory value movwf eedatl ;to write banksel eecon1 ; bcf eecon1,eepgd ;point to data ;memory bsf eecon1,wren ;enable writes bcf intcon,gie ;disable ints. movlw 55h ; movwf eecon2 ;write 55h movlw aah ; movwf eecon2 ;write aah bsf eecon1,wr ;set wr bit to ;begin write bsf intcon,gie ;enable ints. bcf eecon1,wren ;disable writes required sequence
? 2007 microchip technology inc. ds41250f-page 191 pic16f913/914/916/917/946 13.1.4 reading the flash program memory to read a program memory location, the user must write two bytes of the address to the eeadrl and eeadrh registers, set the eepgd control bit, and then set control bit rd of the eecon1 register. once the read control bit is set, the program memory flash controller will use the second instruction cycle to read the data. this causes the second instruction immedi- ately following the ? bsf eecon1,rd ? instruction to be ignored. the data is available in the very next cycle, in the eedatl and eedath registers; therefore, it can be read as two bytes in the following instructions. eedatl and eedath registers will hold this value until another read or until it is written to by the user (during a write operation). example 13-3: flash program read note 1: the two instructions following a program memory read are required to be nop ?s. this prevents the user from executing a two-cycle instruction on the next instruction after the rd bit is set. 2: if the wr bit is set when eepgd = 1 , the wr bit will be immediately reset to ? 0 ? and no operation will take place. banksel eeadrl ; movlw ms_prog_ee_addr; movwf eeadrh ;ms byte of program address to read movlw ls_prog_ee_addr; movwf eeadrl ;ls byte of program address to read banksel eecon1 ; bsf eecon1, eepgd ;point to program memory bsf eecon1, rd ;ee read ; nop nop ;any instructions here are ignored as program ;memory is read in second cycle after bsf ; banksel eedatl ; movf eedatl, w ;w = ls byte of eeprom data program movwf datal ; movf eedath, w ;w = ms byte of eeprom data program movwf datah ; required sequence
pic16f913/914/916/917/946 ds41250f-page 192 ? 2007 microchip technology inc. figure 13-1: flash program me mory read cycle execution table 13-1: summary of associated registers with data eeprom namebit 7bit 6bit 5bit 4bit 3bit 2 bit 1bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 eeadrh ? ? ? eeadrh4 eeadrh3 eeadrh2 eeadrh1 eeadrh0 ---0 0000 ---0 0000 eeadrl eeadrl7 eeadrl6 eeadrl5 eeadrl4 eeadrl3 eeadrl2 eeadrl1 eeadrl0 0000 0000 0000 0000 eecon1 eepgd ? ? ? wrerr wren wr rd 0--- x000 ---- q000 eecon2 eeprom control register 2 (not a physical register) ---- ---- ---- ---- eedath ? ? eedath5 eedath4 eedath3 eedath2 eedath1 eedath0 --00 0000 --00 0000 eedatl eedatl7 eedatl6 eedatl5 eedatl4 eedatl3 eedatl2 eedatl1 eedatl0 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented read as ? 0 ?, q = value depends upon condition. shaded cells are not used by data eeprom module. q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 bsf eecon1,rd executed here instr(pc + 1) executed here forced nop executed here pc pc + 1 eeadrh,eeadrl pc+3 pc + 5 flash addr rd bit eedath,eedatl p c + 3 pc + 4 instr (pc + 1) instr(pc - 1) executed here instr(pc + 3) executed here instr(pc + 4) executed here flash data eedath eedatl register eerhlt instr (pc) instr (pc + 3) instr (pc + 4)
? 2007 microchip technology inc. ds41250f-page 193 pic16f913/914/916/917/946 14.0 ssp module overview the synchronous serial port (ssp) module is a serial interface used to communicate with other peripheral or microcontroller devices. these peripheral devices may be serial eeproms, shift registers, display drivers, a/d converters, etc. the ssp module can operate in one of two modes: ? serial peripheral interface (spi) ? inter-integrated circuit (i 2 c ? ) refer to application note an578, ? use of the ssp module in the multi-master environment ? (ds00578). 14.1 spi mode this section contains register definitions and operational characteristics of the spi module. the spi mode allows 8 bits of data to be synchronously transmitted and received simultaneously. to accomplish communication, typically three pins are used: ? serial data out (sdo) ? serial data in (sdi) ? serial clock (sck) additionally, a fourth pin may be used when in a slave mode of operation: ? slave select (ss ) figure 14-1: ssp block diagram (spi mode) note 1: when the spi is in slave mode with ss pin control enabled (sspm<3:0> bits of the sspcon register = 0100 ), the spi module will reset if the ss pin is set to v dd . 2: if the spi is used in slave mode with cke = 1 , then the ss pin control must be enabled. 3: when the spi is in slave mode with ss pin control enabled (sspm<3:0> bits of the sspcon register = 0100 ), the state of the ss pin can affect the state read back from the trisc<4> bit. the peripheral oe signal from the ssp module into portc controls the state that is read back from the trisc<4> bit (see section 19.0 ?electrical specifications? for information on portc). if read-write-modify instructions, such as bsf, are performed on the trisc register while the ss pin is high, this will cause the trisc<4> bit to be set, thus disabling the sdo output. read write internal data bus sck/ sspsr reg sspbuf reg sspm<3:0> bit 0 shift clock ss control enable edge select clock select tmr2 output t cy prescaler 4, 16, 64 trisc<6> 2 edge select 2 4 scl peripheral oe sdi/sda sdo ss
pic16f913/914/916/917/946 ds41250f-page 194 ? 2007 microchip technology inc. register 14-1: sspstat: sync serial port status register r/w-0 r/w-0 r-0 r-0 r-0 r-0 r-0 r-0 smp cke d/a psr/w ua bf bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 smp : spi data input sample phase bit spi master mode: 1 = input data sampled at end of data output time 0 = input data sampled at middle of data output time (microwire) spi slave mode: smp must be cleared when spi is used in slave mode i 2 c? mode: this bit must be maintained clear bit 6 cke : spi clock edge select bit spi mode, ckp = 0 : 1 = data stable on rising edge of sck (microwire alternate) 0 = data stable on falling edge of sck spi mode, ckp = 1 : 1 = data stable on falling edge of sck (microwire default) 0 = data stable on rising edge of sck i 2 c mode: this bit must be maintained clear bit 5 d/a : data/address bit (i 2 c mode only) 1 = indicates that the last byte received or transmitted was data 0 = indicates that the last byte received or transmitted was address bit 4 p : stop bit (i 2 c mode only) this bit is cleared when the ssp module is dis abled, or when the start bit is detected last. sspen is cleared. 1 = indicates that a stop bit has been detected last (this bit is ? 0 ? on reset) 0 = stop bit was not detected last bit 3 s : start bit (i 2 c mode only) this bit is cleared when the ssp module is dis abled, or when the stop bit is detected last. sspen is cleared. 1 = indicates that a start bit has been detected last (this bit is ? 0 ? on reset) 0 = start bit was not detected last bit 2 r/w : read/write bit information (i 2 c mode only) this bit holds the r/w bit information following the last address match. this bit is only valid from the address match to the next start bit, stop bit or ack bit. 1 = read 0 = write bit 1 ua : update address bit (10-bit i 2 c mode only) 1 = indicates that the user needs to update the address in the sspadd register 0 = address does not need to be updated bit 0 bf : buffer full status bit receive (spi and i 2 c modes): 1 = receive complete, sspbuf is full 0 = receive not complete, sspbuf is empty transmit (i 2 c mode only): 1 = transmit in progress, sspbuf is full 0 = transmit complete, sspbuf is empty
? 2007 microchip technology inc. ds41250f-page 195 pic16f913/914/916/917/946 register 14-2: sspcon: sync se rial port control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 wcol sspov sspen ckp sspm3 (2) sspm2 (2) sspm1 (2) sspm0 (2) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7 wcol : write collision detect bit 1 = the sspbuf register is written while it is still transmitting the previous word (must be cleared in software) 0 = no collision bit 6 sspov : receive overflow indicator bit in spi mode: 1 = a new byte is received while the sspbuf register is still holding the previous data. in case of overflow, the data in sspsr is lost. overflow can only occur in slave mode. the user must read the sspbuf, even if only transmitting data, to avoid setting overflow. in master mode, the overflow bit is not set since each new recep- tion (and transmission) is initiated by writing to the sspbuf register. 0 = no overflow in i 2 c? mode: 1 = a byte is received while the sspbuf register is still holding the previous byte. sspov is a ?don?t care? in transmit mode. sspov must be cleared in software in either mode. 0 = no overflow bit 5 sspen : synchronous serial port enable bit in spi mode: 1 = enables serial port and configures sck, sdo and sdi as serial port pins 0 = disables serial port and confi gures these pins as i/o port pins in i 2 c mode: 1 = enables the serial port and configures the sda and scl pins as serial port pins 0 = disables serial port and confi gures these pins as i/o port pins in both modes, when enabled, these pins must be properly configured as input or output. bit 4 ckp : clock polarity select bit in spi mode: 1 = idle state for clock is a high level (microwire default) 0 = idle state for clock is a low level (microwire alternate) in i 2 c mode: sck release control 1 = enable clock 0 = holds clock low (clock stretch). (used to ensure data setup time.) bit 3-0 sspm<3:0> : synchronous serial port mode select bits 0000 = spi master mode, clock = f osc /4 0001 = spi master mode, clock = f osc /16 0010 = spi master mode, clock = f osc /64 0011 = spi master mode, clock = tmr2 output/2 0100 = spi slave mode, clock = sck pin. ss pin control enabled. 0101 = spi slave mode, clock = sck pin. ss pin control disabled. ss can be used as i/o pin. 0110 = i 2 c slave mode, 7-bit address 0111 = i 2 c slave mode, 10-bit address 1000 = reserved 1001 = reserved 1010 = reserved 1011 = i 2 c firmware controlled master mode (slave idle) 1100 = reserved 1101 = reserved 1110 = i 2 c slave mode, 7-bit address with start and stop bit interrupts enabled 1111 = i 2 c slave mode, 10-bit address with start and stop bit interrupts enabled
pic16f913/914/916/917/946 ds41250f-page 196 ? 2007 microchip technology inc. 14.2 operation when initializing the spi, several options need to be specified. this is done by programming the appropriate control bits (sspcon<5:0> and sspstat<7:6>). these control bits allow the following to be specified: ? master mode (sck is the clock output) ? slave mode (sck is the clock input) ? clock polarity (idle state of sck) ? data input sample phase (middle or end of data output time) ? clock edge (output data on rising/falling edge of sck) ? clock rate (master mode only) ? slave select mode (slave mode only) the ssp consists of a transmit/receive shift register (sspsr) and a buffer register (sspbuf). the sspsr shifts the data in and out of the device, msb first. the sspbuf holds the data that was written to the sspsr until the received data is ready. once the eight bits of data have been received, that byte is moved to the sspbuf register. then, the buffer full status bit bf of the sspstat register, and the interrupt flag bit sspif, are set. any write to the sspbuf register during transmission/reception of data will be ignored and the write collision detect bit, wcol of the sspcon register, will be set. user software must clear the wcol bit so that it can be determined if the following write(s) to the sspbuf register completed successfully. when the application software is expecting to receive valid data, the sspbuf should be read before the next byte of data to transfer is written to the sspbuf. buffer full bit bf of the sspstat register indicates when sspbuf has been loaded with the received data (transmission is complete). when the sspbuf is read, the bf bit is cleared. this data may be irrelevant if the spi is only a transmitter. generally, the ssp interrupt is used to determine when the transmission/reception has completed. the sspbuf must be read and/or written. if the interrupt method is not going to be used, then software polling can be done to ensure that a write collision does not occur. example 14-1 shows the loading of the sspbuf (sspsr) for data transmission. the sspsr is not directly readable or writable and can only be accessed by addressing the sspbuf register. additionally, the ssp status register (sspstat) indicates the various status conditions. example 14-1: loading the sspbuf (sspsr) register banksel sspstat ; loop btfss sspstat, bf ;has data been received(transmit complete)? goto loop ;no banksel sspbuf ; movf sspbuf, w ;wreg reg = contents of sspbuf movwf rxdata ;save in user ram, if data is meaningful movf txdata, w ;w reg = contents of txdata movwf sspbuf ;new data to xmit
? 2007 microchip technology inc. ds41250f-page 197 pic16f913/914/916/917/946 14.3 enabling spi i/o to enable the serial port, ssp enable bit sspen of the sspcon register must be set. to reset or reconfigure spi mode, clear the sspen bit, re-initialize the sspcon registers and then set the sspen bit. this configures the sdi, sdo, sck and ss pins as serial port pins. for the pins to behave as the serial port function, their data direction bits (in the trisa and trisc registers) should be set as follows: ? trisc<7> bit must be set ? sdi is automatically controlled by the spi module ? sdo must have trisc<4> bit cleared ? sck (master mode) must have trisc<6> bit cleared ? sck (slave mode) must have trisc<6> bit set ? if enabled, ss must have trisa<5> bit set any serial port function that is not desired may be overridden by programming the corresponding data direction (trisa and trisc) registers to the opposite value. 14.4 typical connection figure 14-2 shows a typical connection between two microcontrollers. the master controller (processor 1) initiates the data transfer by sending the sck signal. data is shifted out of both shift registers on their programmed clock edge and latched on the opposite edge of the clock. both processors should be programmed to the same clock polarity (ckp), then both controllers would send and receive data at the same time. whether the data is meaningful (or dummy data) depends on the application software. this leads to three scenarios for data transmission: ? master sends data ? slave sends dummy data ? master sends data ? slave sends data ? master sends dummy data ? slave sends data figure 14-2: spi master/s lave connection serial input buffer (sspbuf) shift register (sspsr) msb lsb sdo sdi processor 1 sck spi master sspm<3:0> = 00xxb serial input buffer (sspbuf) shift register (sspsr) lsb msb sdi sdo processor 2 sck spi slave sspm<3:0> = 010xb serial clock
pic16f913/914/916/917/946 ds41250f-page 198 ? 2007 microchip technology inc. 14.5 master mode the master can initiate the data transfer at any time because it controls the sck. the master determines when the slave (processor 2, figure 14-2) is to broadcast data by the software protocol. in master mode, the data is transmitted/received as soon as the sspbuf register is written to. if the spi is only going to receive, the sdo output could be disabled (programmed as an input). the sspsr register will continue to shift in the signal present on the sdi pin at the programmed clock rate. as each byte is received, it will be loaded into the sspbuf register as if a normal received byte (interrupts and status bits appropriately set). this could be useful in receiver applications as a line activity monitor mode. the clock polarity is selected by appropriately programming the ckp bit of the sspcon register. this then, would give waveforms for spi communication as shown in figure 14-3, figure 14-5 and figure 14-6, where the msb is transmitted first. in master mode, the spi clock rate (bit rate) is user programmable to be one of the following: ?f osc /4 (or t cy ) ?f osc /16 (or 4 ? t cy ) ?f osc /64 (or 16 ? t cy ) ? timer2 output/2 this allows a maximum data rate (at 20 mhz) of 5 mbps. figure 14-3 shows the waveforms for master mode. when the cke bit is set, the sdo data is valid before there is a clock edge on sck. the change of the input sample is shown based on the state of the smp bit. the time when the sspbuf is loaded with the received data is shown. figure 14-3: spi mode waveform (master mode) sck (ckp = 0 sck (ckp = 1 sck (ckp = 0 sck (ckp = 1 4 clock modes input sample input sample sdi bit 7 bit 0 sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 7 bit 0 sdi sspif (smp = 1 ) (smp = 0 ) (smp = 1 ) cke = 1 ) cke = 0 ) cke = 1 ) cke = 0 ) (smp = 0 ) write to sspbuf sspsr to sspbuf sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 (cke = 0 ) (cke = 1 ) next q4 cycle after q2
? 2007 microchip technology inc. ds41250f-page 199 pic16f913/914/916/917/946 14.6 slave mode in slave mode, the data is transmitted and received as the external clock pulses appear on sck. when the last bit is latched, the sspif interrupt flag bit is set. while in slave mode, the external clock is supplied by the external clock source on the sck pin. this external clock must meet the minimum high and low times as specified in the electrical specifications. while in sleep mode, the slave can transmit/receive data. when a byte is received, the device will wake-up from sleep. 14.7 slave select synchronization the ss pin allows a synchronous slave mode. the spi must be in slave mode with ss pin control enabled (sspcon<3:0> = 0100 ). the pin must not be driven low for the ss pin to function as an input. the data latch must be high. when the ss pin is low, transmission and reception are enabled and the sdo pin is driven. when the ss pin goes high, the sdo pin is no longer driven, even if in the middle of a transmitted byte, and becomes a floating output. external pull-up/pull-down resistors may be desirable, depending on the application. when the spi module resets, the bit counter is forced to 0. this can be done by either forcing the ss pin to a high level or clearing the sspen bit. to emulate two-wire communication, the sdo pin can be connected to the sdi pin. when the spi needs to operate as a receiver, the sdo pin can be configured as an input. this disables transmissions from the sdo. the sdi can always be left as an input (sdi function) since it cannot create a bus conflict. figure 14-4: slave synchroniza tion waveform note 1: when the spi is in slave mode with ss pin control enabled (sspcon<3:0> = 0100 ), the spi module will reset if the ss pin is set to v dd . 2: if the spi is used in slave mode with cke set, then the ss pin control must be enabled. sck (ckp = 1 sck (ckp = 0 input sample sdi bit 7 sdo bit 7 bit 6 bit 7 sspif interrupt (smp = 0 ) cke = 0 ) cke = 0 ) (smp = 0 ) write to sspbuf sspsr to sspbuf ss flag bit 0 bit 7 bit 0 next q4 cycle after q2
pic16f913/914/916/917/946 ds41250f-page 200 ? 2007 microchip technology inc. figure 14-5: spi mode waveform (slave mode with cke = 0 ) figure 14-6: spi mode waveform (slave mode with cke = 1 ) sck (ckp = 1 sck (ckp = 0 input sample sdi bit 7 bit 0 sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sspif interrupt (smp = 0 ) cke = 0 ) cke = 0 ) (smp = 0 ) write to sspbuf sspsr to sspbuf ss flag optional next q4 cycle after q2 sck (ckp = 1 sck (ckp = 0 input sample sdi bit 7 bit 0 sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sspif interrupt (smp = 0 ) cke = 1 ) cke = 1 ) (smp = 0 ) write to sspbuf sspsr to sspbuf ss flag not optional next q4 cycle after q2
? 2007 microchip technology inc. ds41250f-page 201 pic16f913/914/916/917/946 14.8 sleep operation in master mode, all module clocks are halted and the transmission/reception will remain in that state until the device wakes from sleep. after the device returns to normal mode, the module will continue to transmit/receive data. in slave mode, the spi transmit/receive shift register operates asynchronously to the device. this allows the device to be placed in sleep mode and data to be shifted into the spi transmit/receive shift register. when all 8 bits have been received, the ssp interrupt flag bit will be set and if enabled, will wake the device from sleep. 14.9 effects of a reset a reset disables the ssp module and terminates the current transfer. 14.10 bus mode compatibility table 14-1 shows the compatibility between the standard spi modes and the states of the ckp and cke control bits. table 14-1: spi bus modes there is also a smp bit which controls when the data is sampled. table 14-2: summary of registers associated with spi operation standard spi mode terminology control bits state ckp cke 0 , 001 0 , 100 1 , 011 1 , 110 name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 0000 0000 0000 0000 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx uuuu uuuu sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 sspstat smp cke d/a p s r/w ua bf 0000 0000 0000 0000 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 1111 1111 1111 1111 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used by the ssp in spi mode.
pic16f913/914/916/917/946 ds41250f-page 202 ? 2007 microchip technology inc. 14.11 ssp i 2 c operation the ssp module in i 2 c mode, fully implements all slave functions, except general call support, and provides interrupts on start and stop bits in hardware to facilitate firmware implementations of the master functions. the ssp module implements the standard mode specifications, as well as 7-bit and 10-bit addressing. two pins are used for data transfer. these are the rc6/tx/ck/sck/scl/seg9 pin, which is the clock (scl), and the rc7/rx/dt/sdi/sda/seg8 pin, which is the data (sda). the ssp module functions are enabled by setting ssp enable bit sspen (sspcon<5>). figure 14-7: ssp block diagram (i 2 c? mode) the ssp module has five registers for the i 2 c operation, which are listed below. ? ssp control register (sspcon) ? ssp status register (sspstat) ? serial receive/transmit buffer (sspbuf) ? ssp shift register (sspsr) ? not directly accessible ? ssp address register (sspadd) the sspcon register allows control of the i 2 c operation. four mode selection bits (sspcon<3:0>) allow one of the following i 2 c modes to be selected: ?i 2 c slave mode (7-bit address) ?i 2 c slave mode (10-bit address) ?i 2 c slave mode (7-bit address), with start and stop bit interrupts enabled to support firmware master mode ?i 2 c slave mode (10-bit address), with start and stop bit interrupts enabled to support firmware master mode ?i 2 c start and stop bit interrupts enabled to support firmware master mode; slave is idle selection of any i 2 c mode with the sspen bit set forces the scl and sda pins to be open drain, provided these pins are programmed to inputs by setting the appropriate trisc bits. pull-up resistors must be provided externally to the scl and sda pins for proper operation of the i 2 c module. 14.12 slave mode in slave mode, the scl and sda pins must be configured as inputs (trisc<7,6> are set). the ssp module will override the input state with the output data when required (slave-transmitter). when an address is matched, or the data transfer after an address match is received, the hardware automatically will generate the acknowledge (ack ) pulse, and then load the sspbuf register with the received value currently in the sspsr register. there are certain conditions that will cause the ssp module not to give this ack pulse. they include (either or both): a) the buffer full bit bf of the sspstat register was set before the transfer was received. b) the overflow bit sspov of the sspcon register was set before the transfer was received. in this case, the sspsr register value is not loaded into the sspbuf, but bit sspif of the pir1 register is set. table 14-3 shows the results of when a data transfer byte is received, given the status of bits bf and sspov. the shaded cells show the condition where user software did not properly clear the overflow condition. flag bit bf is cleared by reading the sspbuf register, while bit sspov is cleared through software. the scl clock input must have a minimum high and low for proper operation. for high and low times of the i 2 c specification, as well as the requirements of the ssp module, see section 19.0 ?electrical specifications? . read write sspsr reg match detect sspadd reg start and stop bit detect sspbuf reg internal data bus addr match set, reset s, p bits (sspstat reg.) shift clock msb lsb sdi/ scl sck/ sda
? 2007 microchip technology inc. ds41250f-page 203 pic16f913/914/916/917/946 14.12.1 addressing once the ssp module has been enabled, it waits for a start condition to occur. following the start condition, the 8-bits are shifted into the sspsr register. all incoming bits are sampled with the rising edge of the clock (scl) line. the value of register sspsr<7:1> is compared to the value of register sspadd <7:1>. the address is compared on the falling edge of the eighth clock (scl) pulse. if the addresses match, and the bf and sspov bits are clear, the following events occur: a) the sspsr register value is loaded into the sspbuf register. b) the buffer full bit, bf is set. c) an ack pulse is generated. d) ssp interrupt flag bit, sspif of the pir1 register is set (interrupt is generated if enabled) on the falling edge of the ninth scl pulse. in 10-bit address mode, two address bytes need to be received by the slave (figure 14-8). the five most significant bits (msbs) of the first address byte specify if this is a 10-bit address. bit r/w (sspstat<2>) must specify a write so the slave device will receive the second address byte. for a 10-bit address, the first byte would equal ? 1111 0 a9 a8 0 ?, where a9 and a8 are the two msbs of the address. the sequence of events for 10-bit address is as follows, with steps 7-9 for slave-transmitter: 1. receive first (high) byte of address (bits sspif, bf and bit ua (sspstat<1>) are set). 2. update the sspadd register with second (low) byte of address (clears bit ua and releases the scl line). 3. read the sspbuf register (clears bit bf) and clear flag bit sspif. 4. receive second (low) byte of address (bits sspif, bf and ua are set). 5. update the sspadd register with the first (high) byte of address; if match releases scl line, this will clear bit ua. 6. read the sspbuf register (clears bit bf) and clear flag bit sspif. 7. receive repeated start condition. 8. receive first (high) byte of address (bits sspif and bf are set). 9. read the sspbuf register (clears bit bf) and clear flag bit sspif. table 14-3: data transfer received byte actions status bits as data transfer is received sspsr sspbuf generate ack pulse set bit sspif (ssp interrupt occurs if enabled) bf sspov 00 yes yes yes 10 no no yes 11 no no yes 0 1 no no yes note: shaded cells show the conditions where the user software did not properly clear the overflow condition.
pic16f913/914/916/917/946 ds41250f-page 204 ? 2007 microchip technology inc. 14.12.2 reception when the r/w bit of the address byte is clear and an address match occurs, the r/w bit of the sspstat register is cleared. the received address is loaded into the sspbuf register. when the address byte overflow condition exists, then no acknowledge (ack ) pulse is given. an overflow condition is defined as either bit bf of the sspstat register is set, or bit sspov of the sspcon register is set. this is an error condition due to the user?s firm- ware. an ssp interrupt is generated for each data transfer byte. flag bit sspif of the pir1 register must be cleared in software. the sspstat register is used to determine the status of the byte. figure 14-8: i 2 c? waveforms for reception (7-bit address) p 9 8 7 6 5 d0 d1 d2 d3 d4 d5 d6 d7 s a7 a6 a5 a4 a3 a2 a1 sda scl 1 2 34 56 78 9123 4 56 7 89 12 34 bus master terminates transfer bit sspov is set because the sspbuf register is still full. cleared in software sspbuf register is read ack receiving data receiving data d0 d1 d2 d3 d4 d5 d6 d7 ack r/w = 0 receiving address sspif (pir1<3>) bf (sspstat<0>) sspov (sspcon<6>) ack ack is not sent.
? 2007 microchip technology inc. ds41250f-page 205 pic16f913/914/916/917/946 figure 14-9: i 2 c? slave mode timing (reception, 10-bit address) sspif bf (sspstat<0>) receive data byte r/w = 0 receive first byte of address cleared in software (pir1<3>) cleared in software receive second byte of address cleared by hardware when sspadd is updated with low byte of address ua (sspstat<1>) clock is held low until update of sspadd has taken place ua is set indicating that the sspadd needs to be updated ua is set indicating that sspadd needs to be updated cleared by hardware when sspadd is updated with high byte of address sspbuf is written with contents of sspsr dummy read of sspbuf to clear bf flag ckp receive data byte bus master terminates transfer ack cleared in software cleared in software sspov (sspcon<6>) sspov is set because sspbuf is still full. ack is not sent. (ckp does not reset to ? 0 ? when sen = 0 ) clock is held low until update of sspadd has taken place sda scl s 12345 6 789 123 4567 89 12345 78 9 p 1111 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 d7 d6 d5 d4 d3 d1 d0 ack ack d2 6 ack 1 23 4 5789 d7 d6 d5 d4 d3 d1 d0 d2 6 ack 0
pic16f913/914/916/917/946 ds41250f-page 206 ? 2007 microchip technology inc. 14.12.3 transmission when the r/w bit of the incoming address byte is set and an address match occurs, the r/w bit of the sspstat register is set. the received address is loaded into the sspbuf register. the ack pulse will be sent on the ninth bit, and pin rc6/tx/ck/sck/scl/seg9 is held low. the transmit data must be loaded into the sspbuf register, which also loads the sspsr register. then, pin rc6/tx/ck/sck/scl/seg9 should be enabled by setting bit ckp of the sspcon register. the master must monitor the scl pin prior to asserting another clock pulse. the slave devices may be holding off the master by stretching the clock. the eight data bits are shifted out on the falling edge of the scl input. this ensures that the sda signal is valid during the scl high time (figure 14-10). an ssp interrupt is generated for each data transfer byte. flag bit sspif must be cleared in software, and the sspstat register is used to determine the status of the byte. flag bit sspif is set on the falling edge of the ninth clock pulse. as a slave-transmitter, the ack pulse from the master receiver is latched on the rising edge of the ninth scl input pulse. if the sda line was high (not ack ), then the data transfer is complete. when the ack is latched by the slave, the slave logic is reset (resets sspstat register) and the slave then monitors for another occurrence of the start bit. if the sda line was low (ack ), the transmit data must be loaded into the sspbuf register, which also loads the sspsr register. then pin rc6/tx/ck/sck/scl/seg9 should be enabled by setting bit ckp. figure 14-10: i 2 c? waveforms for transmission (7-bit address) sda scl sspif (pir1<3>) bf (sspstat<0>) ckp (sspcon<4>) a7 a6 a5 a4 a3 a2 a1 ack d7 d6 d5 d4 d3 d2 d1 d0 ack transmitting data r/w = 1 receiving address 123456789 123456789 p cleared in software sspbuf is written in software from ssp interrupt service routine set bit after writing to sspbuf s data in sampled scl held low while cpu responds to sspif (the sspbuf must be written to before the ckp bit can be set)
? 2007 microchip technology inc. ds41250f-page 207 pic16f913/914/916/917/946 figure 14-11: i 2 c? slave mode timing (transmission, 10-bit address) sda scl sspif bf (sspstat<0>) s 12 34 5678 9 123 4567 89 12345 78 9 p 1111 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 d7 d6 d5 d4 d3 d1 d0 receive data byte ack r/w = 0 ack receive first byte of address cleared in software d2 6 (pir1<3>) cleared in software receive second byte of address cleared by hardware when sspadd is updated with low byte of address ua (sspstat<1>) clock is held low until update of sspadd has taken place ua is set indicating that the sspadd needs to be updated ua is set indicating that sspadd needs to be updated cleared by hardware when sspadd is updated with high byte of address sspbuf is written with contents of sspsr dummy read of sspbuf to clear bf flag ack ckp 1 23 4 5789 d7 d6 d5 d4 d3 d1 d0 receive data byte bus master terminates transfer d2 6 ack cleared in software cleared in software sspov (sspcon<6>) sspov is set because sspbuf is still full. ack is not sent. (ckp does not reset to ? 0 ? when sen = 0 ) clock is held low until update of sspadd has taken place 0
pic16f913/914/916/917/946 ds41250f-page 208 ? 2007 microchip technology inc. 14.13 master mode master mode of operation is supported in firmware using interrupt generation on the detection of the start and stop conditions. the stop (p) and start (s) bits are cleared from a reset or when the ssp module is disabled. the stop (p) and start (s) bits will toggle based on the start and stop conditions. control of the i 2 c bus may be taken when the p bit is set or the bus is idle and both the s and p bits are clear. in master mode, the scl and sda lines are manipulated by clearing the corresponding trisc<7,6> bit(s). the output level is always low, irrespective of the value(s) in portc<7,6>. so when transmitting data, a ? 1 ? data bit must have the trisc<6> bit set (input) and a ? 0 ? data bit must have the trisc<7> bit cleared (output). the same scenario is true for the scl line with the trisc<6> bit. pull-up resistors must be provided externally to the scl and sda pins for proper operation of the i 2 c module. the following events will cause the ssp interrupt flag bit, sspif, to be set (ssp interrupt will occur if enabled): ? start condition ? stop condition ? data transfer byte transmitted/received master mode of operation can be done with either the slave mode idle (sspm<3:0> = 1011 ), or with the slave active. when both master and slave modes are enabled, the software needs to differentiate the source(s) of the interrupt. 14.14 multi-master mode in multi-master mode, the interrupt generation on the detection of the start and stop conditions, allows the determination of when the bus is free. the stop (p) and start (s) bits are cleared from a reset or when the ssp module is disabled. the stop (p) and start (s) bits will toggle based on the start and stop conditions. control of the i 2 c bus may be taken when bit p (sspstat<4>) is set, or the bus is idle and both the s and p bits clear. when the bus is busy, enabling the ssp interrupt will generate the interrupt when the stop condition occurs. in multi-master operation, the sda line must be monitored to see if the signal level is the expected output level. this check only needs to be done when a high level is output. if a high level is expected and a low level is present, the device needs to release the sda and scl lines (set trisc<7,6>). there are two stages where this arbitration can be lost, these are: ? address transfer ? data transfer when the slave logic is enabled, the slave continues to receive. if arbitration was lost during the address transfer stage, communication to the device may be in progress. if addressed, an ack pulse will be generated. if arbitration was lost during the data transfer stage, the device will need to re-transfer the data at a later time. 14.14.1 clock synchronization and the ckp bit when the ckp bit is cleared, the scl output is forced to ? 0 ?; however, setting the ckp bit will not assert the scl output low until the scl output is already sampled low. therefore, the ckp bit will not assert the scl line until an external i 2 c master device has already asserted the scl line. the scl output will remain low until the ckp bit is set and all other devices on the i 2 c bus have deasserted scl. this ensures that a write to the ckp bit will not violate the minimum high time requirement for scl (see figure 14-12).
? 2007 microchip technology inc. ds41250f-page 209 pic16f913/914/916/917/946 figure 14-12: clock synchronization timing table 14-4: summary of registers associated with i 2 c? operation name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2if tmr1if 0000 0000 0000 0000 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx uuuu uuuu sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 sspstat smp (1) cke (1) d/a psr/w ua bf 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 legend: ? = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the ssp module. note 1: maintain these bits clear. sda scl dx-1 dx wr q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 sspcon ckp master device deasserts clock master device asserts clock
pic16f913/914/916/917/946 ds41250f-page 210 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 211 pic16f913/914/916/917/946 15.0 capture/compare/pwm (ccp) module the capture/compare/pwm module is a peripheral which allows the user to time and control different events. in capture mode, the peripheral allows the timing of the duration of an event. the compare mode allows the user to trigger an external event when a predetermined amount of time has expired. the pwm mode can generate a pulse-width modulated signal of varying frequency and duty cycle. the timer resources used by the module are shown in table 15-1. additional information on ccp modules is available in the application note an594, ?using the ccp modules? (ds00594). table 15-1: ccp mode ? timer resources required table 15-2: interaction of two ccp modules ccp mode timer resource capture timer1 compare timer1 pwm timer2 ccpx mode ccpy mode interaction capture capture same tmr1 time base capture compare same tmr1 time base compare compare same tmr1 time base pwm pwm the pwms will have the same frequency and update rate (tmr2 interrupt). the rising edges will be aligned. pwm capture none pwm compare none note: ccprx and ccpx throughout this document refer to ccpr1 or ccpr2 and ccp1 or ccp2, respectively.
pic16f913/914/916/917/946 ds41250f-page 212 ? 2007 microchip technology inc. register 15-1: ccpxcon: ccpx control register u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? ccpxx ccpxy ccp1m3 ccp1m2 ccp1m1 ccp1m0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 7-6 unimplemented: read as ? 0 ? bit 5-4 ccpxx:ccpxy : pwm least significant bits capture mode : unused compare mode: unused pwm mode: these bits are the two lsbs of the pwm duty cycle. the eight msbs are found in ccprxl. bit 3-0 ccpxm<3:0>: ccp mode select bits 0000 = capture/compare/pwm off (resets ccp module) 0001 = unused (reserved) 0010 = unused (reserved) 0011 = unused (reserved) 0100 = capture mode, every falling edge 0101 = capture mode, every rising edge 0110 = capture mode, every 4th rising edge 0111 = capture mode, every 16th rising edge 1000 = compare mode, set output on match (ccpxif bit is set) 1001 = compare mode, clear output on match (ccpxif bit is set) 1010 = compare mode, generate software interrupt on match (ccpxif bit is set, ccpx pin is unaffected) 1011 = compare mode, trigger special event (ccpxif bit is set, tmr1 is reset and a/d conversion is started if the adc module is enabled. ccpx pin is unaffected.) 11xx =pwm mode.
? 2007 microchip technology inc. ds41250f-page 213 pic16f913/914/916/917/946 15.1 capture mode in capture mode, ccprxh:ccprxl captures the 16-bit value of the tmr1 register when an event occurs on pin ccpx. an event is defined as one of the following and is configured by the ccpxm<3:0> bits of the ccpxcon register: ? every falling edge ? every rising edge ? every 4th rising edge ? every 16th rising edge when a capture is made, the interrupt request flag bit ccpxif of the pirx register is set. the interrupt flag must be cleared in software. if another capture occurs before the value in the ccprxh, ccprxl register pair is read, the old captured value is overwritten by the new captured value (see figure 15-1). 15.1.1 ccpx pin configuration in capture mode, the ccpx pin should be configured as an input by setting the associated tris control bit. figure 15-1: capture mode operation block diagram 15.1.2 timer1 mode selection timer1 must be running in timer mode or synchronized counter mode for the ccp module to use the capture feature. in asynchronous counter mode, the capture operation may not work. 15.1.3 software interrupt when the capture mode is changed, a false capture interrupt may be generated. the user should keep the ccpxie interrupt enable bit of the piex register clear to avoid false interrupts. additionally, the user should clear the ccpxif interrupt flag bit of the pirx register following any change in operating mode. 15.1.4 ccp prescaler there are four prescaler settings specified by the ccpxm<3:0> bits of the ccpxcon register. whenever the ccp module is turned off, or the ccp module is not in capture mode, the prescaler counter is cleared. any reset will clear the prescaler counter. switching from one capture prescaler to another does not clear the prescaler and may generate a false interrupt. to avoid this unexpected operation, turn the module off by clearing the ccpxcon register before changing the prescaler (see example 15-1). example 15-1: changing between capture prescalers note: if the ccpx pin is configured as an output, a write to the port can cause a capture condition. ccprxh ccprxl tmr1h tmr1l set flag bit ccpxif (pirx register) capture enable ccpxcon<3:0> prescaler 1, 4, 16 and edge detect pin ccpx system clock (f osc ) banksel ccp1con ;set bank bits to point ;to ccp1con clrf ccp1con ;turn ccp module off movlw new_capt_ps ;load the w reg with ; the new prescaler ; move value and ccp on movwf ccp1con ;load ccp1con with this ; value
pic16f913/914/916/917/946 ds41250f-page 214 ? 2007 microchip technology inc. 15.2 compare mode in compare mode, the 16-bit ccprx register value is constantly compared against the tmr1 register pair value. when a match occurs, the ccpx module may: ? toggle the ccpx output. ? set the ccpx output. ? clear the ccpx output. ? generate a special event trigger. ? generate a software interrupt. the action on the pin is based on the value of the ccpxm<3:0> control bits of the ccpxcon register. all compare modes can generate an interrupt. figure 15-2: compare mode operation block diagram 15.2.1 ccpx pin configuration the user must configure the ccpx pin as an output by clearing the associated tris bit. 15.2.2 timer1 mode selection in compare mode, timer1 must be running in either timer mode or synchronized counter mode. the compare operation may not work in asynchronous counter mode. 15.2.3 software interrupt mode when generate software interrupt mode is chosen (ccpxm<3:0> = 1010 ), the ccpx module does not assert control of the ccpx pin (see the ccpxcon register). 15.2.4 special event trigger when special event trigger mode is chosen (ccpxm<3:0> = 1011 ), the ccpx module does the following: ? resets timer1 ? starts an adc conversion if adc is enabled the ccpx module does not assert control of the ccpx pin in this mode (see the ccpxcon register). the special event trigger output of the ccp occurs immediately upon a match between the tmr1h, tmr1l register pair and the ccprxh, ccprxl register pair. the tmr1h, tmr1l register pair is not reset until the next rising edge of the timer1 clock. this allows the ccprxh, ccprxl register pair to effectively provide a 16-bit programmable period register for timer1. note: clearing the ccpxcon register will force the ccpx compare output latch to the default low level. this is not the port i/o data latch. ccprxh ccprxl tmr1h tmr1l comparator qs r output logic special event trigger set ccpxif interrupt flag (pirx) match tris ccpxcon<3:0> mode select output enable pin special event trigger will: ? clear tmr1h and tmr1l registers. ? not set interrupt flag bit tmr1if of the pir1 register. ? set the go/done bit to start the adc conversion. ccpx 4 note 1: the special event trigger from the ccp module does not set interrupt flag bit tmrxif of the pir1 register. 2: removing the match condition by changing the contents of the ccprxh and ccprxl register pair, between the clock edge that generates the special event trigger and the clock edge that generates the timer1 reset, will preclude the reset from occurring.
? 2007 microchip technology inc. ds41250f-page 215 pic16f913/914/916/917/946 15.3 pwm mode the pwm mode generates a pulse-width modulated signal on the ccpx pin. the duty cycle, period and resolution are determined by the following registers: ?pr2 ?t2con ? ccprxl ? ccpxcon in pulse-width modulation (pwm) mode, the ccp module produces up to a 10-bit resolution pwm output on the ccpx pin. since the ccpx pin is multiplexed with the port data latch, the tris for that pin must be cleared to enable the ccpx pin output driver. figure 15-3 shows a simplified block diagram of pwm operation. figure 15-4 shows a typical waveform of the pwm signal. for a step-by-step procedure on how to set up the ccp module for pwm operation, see section 15.3.7 ?setup for pwm operation? . figure 15-3: simplified pwm block diagram the pwm output (figure 15-2) has a time base (period) and a time that the output stays high (duty cycle). figure 15-4: ccp pwm output note: clearing the ccpxcon register will relinquish ccpx control of the ccpx pin. ccprxl ccpr x h (2) (slave) comparator tmr2 pr2 (1) rq s duty cycle registers ccpxcon<5:4> clear timer2, toggle ccp x pin and latch duty cycle note 1: the 8-bit timer tmr2 register is concatenated with the 2-bit internal system clock (f osc ), or 2 bits of the prescaler, to create the 10-bit time base. 2: in pwm mode, ccprxh is a read-only register. tris ccpx comparator period pulse width tmr2 = 0 tmr2 = ccprxl:ccpxcon<5:4> tmr2 = pr2
pic16f913/914/916/917/946 ds41250f-page 216 ? 2007 microchip technology inc. 15.3.1 pwm period the pwm period is specified by the pr2 register of timer2. the pwm period can be calculated using the formula of equation 15-1. equation 15-1: pwm period when tmr2 is equal to pr2, the following three events occur on the next increment cycle: ? tmr2 is cleared ? the ccpx pin is set. (exception: if the pwm duty cycle = 0%, the pin will not be set.) ? the pwm duty cycle is latched from ccprxl into ccprxh. 15.3.2 pwm duty cycle the pwm duty cycle is specified by writing a 10-bit value to multiple registers: ccprxl register and ccpx<1:0> bits of the ccpxcon register. the ccprxl contains the eight msbs and the ccpx<1:0> bits of the ccpxcon register contain the two lsbs. ccprxl and ccpx<1:0> bits of the ccpxcon register can be written to at any time. the duty cycle value is not latched into ccprxh until after the period completes (i.e., a match between pr2 and tmr2 registers occurs). while using the pwm, the ccprxh register is read-only. equation 15-2 is used to calculate the pwm pulse width. equation 15-3 is used to calculate the pwm duty cycle ratio. equation 15-2: pulse width equation 15-3: duty cycle ratio the ccprxh register and a 2-bit internal latch are used to double buffer the pwm duty cycle. this double buffering is essential for glitchless pwm operation. the 8-bit timer tmr2 register is concatenated with either the 2-bit internal system clock (f osc ), or 2 bits of the prescaler, to create the 10-bit time base. the system clock is used if the timer2 prescaler is set to 1:1. when the 10-bit time base matches the ccprxh and 2-bit latch, then the ccpx pin is cleared (see figure 15-3). note: the timer2 postscaler (see section 7.1 ?timer2 operation? ) is not used in the determination of the pwm frequency. pwm period pr2 () 1 + [] 4t osc ? ? ? = (tmr2 prescale value) note: t osc = 1/f osc pulse width ccprxl:ccpxcon<5:4> () ? = t osc ? (tmr2 prescale value) duty cycle ratio ccprxl:ccpxcon<5:4> () 4pr2 1 + () ---------------------------------------------------------------------- - =
? 2007 microchip technology inc. ds41250f-page 217 pic16f913/914/916/917/946 15.3.3 pwm resolution the resolution determines the number of available duty cycles for a given period. for example, a 10-bit resolution will result in 1024 discrete duty cycles, whereas an 8-bit resolution will result in 256 discrete duty cycles. the maximum pwm resolution is 10 bits when pr2 is 255. the resolution is a function of the pr2 register value as shown by equation 15-4. equation 15-4: pwm resolution table 15-3: example pwm frequencies and resolutions (f osc = 20 mhz) table 15-4: example pwm frequencies and resolutions (f osc = 8 mhz) note: if the pulse width value is greater than the period the assigned pwm pin(s) will remain unchanged. resolution 4pr2 1 + () [] log 2 () log ----------------------------------------- - bits = pwm frequency 1.22 khz 4.88 khz 19.53 khz 78.12 khz 156.3 khz 208.3 khz timer prescale (1, 4, 16) 16 4 1 1 1 1 pr2 value 0xff 0xff 0xff 0x3f 0x1f 0x17 maximum resolution (bits) 10 10 10 8 7 6.6 pwm frequency 1.22 khz 4.90 khz 19.61 khz 76.92 khz 153.85 khz 200.0 khz timer prescale (1, 4, 16) 16 4 1 1 1 1 pr2 value 0x65 0x65 0x65 0x19 0x0c 0x09 maximum resolution (bits) 8 8 8 6 5 5
pic16f913/914/916/917/946 ds41250f-page 218 ? 2007 microchip technology inc. 15.3.4 operation in sleep mode in sleep mode, the tmr2 register will not increment and the state of the module will not change. if the ccpx pin is driving a value, it will continue to drive that value. when the device wakes up, tmr2 will continue from its previous state. 15.3.5 changes in system clock frequency the pwm frequency is derived from the system clock frequency. any changes in the system clock frequency will result in changes to the pwm frequency. see section 4.0 ?oscillator module (with fail-safe clock monitor)? for additional details. 15.3.6 effects of reset any reset will force all ports to input mode and the ccp registers to their reset states. 15.3.7 setup for pwm operation the following steps should be taken when configuring the ccp module for pwm operation: 1. disable the pwm pin (ccpx) output drivers by setting the associated tris bit. 2. set the pwm period by loading the pr2 register. 3. configure the ccp module for the pwm mode by loading the ccpxcon register with the appropriate values. 4. set the pwm duty cycle by loading the ccprxl register and ccpx bits of the ccpxcon register. 5. configure and start timer2: ? clear the tmr2if interrupt flag bit of the pir1 register. ? set the timer2 prescale value by loading the t2ckps bits of the t2con register. ? enable timer2 by setting the tmr2on bit of the t2con register. 6. enable pwm output after a new pwm cycle has started: ? wait until timer2 overflows (tmr2if bit of the pir1 register is set). ? enable the ccpx pin output driver by clearing the associated tris bit. table 15-5: summary of registers asso ciated with capture, compare and pwm name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets ccpxcon ? ? ccpxx ccpxy ccpxm3 ccpxm2 ccpxm1 ccpxm0 --00 0000 --00 0000 ccprxl capture/compare/pwm register x low byte xxxx xxxx uuuu uuuu ccprxh capture/compare/pwm register x high byte xxxx xxxx uuuu uuuu cmcon1 ? ? ? ? ? ? t1gss c2sync ---- --10 ---- --10 intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x lcdcon lcden slpen werr vlcden cs1 cs0 lmux1 lmux0 0001 0011 0001 0011 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 0000 0000 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pie2 osfie c2ie c1ie lcdie ? lvdie ?ccp2ie 0000 -0-0 0000 -0-0 pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pir2 osfif c2if c1if lcdif ? lvdif ?ccp2if 0000 -0-0 0000 -0-0 rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x sspcon wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 t1con t1ginv tmr1ge t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on 0000 0000 uuuu uuuu t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu tmr2 timer2 module register 0000 0000 0000 0000 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 1111 1111 1111 1111 trisd (1) trisd7 trisd6 trisd5 trisd4 trisd3 trisd2 trisd1 trisd0 1111 1111 1111 1111 legend: - = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the capture, compare and pwm. note 1: pic16F914/917 and pic16f946 only.
? 2007 microchip technology inc. ds41250f-page 219 pic16f913/914/916/917/946 16.0 special features of the cpu the pic16f91x/946 has a host of features intended to maximize system reliability, minimize cost through elimination of external components, provide power-saving features and offer code protection. these features are: ? reset - power-on reset (por) - power-up timer (pwrt) - oscillator start-up timer (ost) - brown-out reset (bor) ? interrupts ? watchdog timer (wdt) ? oscillator selection ? sleep ? code protection ? id locations ? in-circuit serial programming? the pic16f91x/946 has two timers that offer necessary delays on power-up. one is the oscillator start-up timer (ost), intended to keep the chip in reset until the crystal oscillator is stable. the other is the power-up timer (pwrt), which provides a fixed delay of 64 ms (nominal) on power-up only, designed to keep the part in reset while the power supply stabilizes. there is also circuitry to reset the device if a brown-out occurs, which can use the power-up timer to provide at least a 64 ms reset. with these three functions-on-chip, most applications need no external reset circuitry. the sleep mode is designed to offer a very low-current power-down mode. the user can wake-up from sleep through: ?external reset ? watchdog timer wake-up ? an interrupt several oscillator options are also made available to allow the part to fit the application. the intosc option saves system cost, while the lp crystal option saves power. a set of configuration bits are used to select various options (see register 16-1).
pic16f913/914/916/917/946 ds41250f-page 220 ? 2007 microchip technology inc. 16.1 configuration bits the configuration bits can be programmed (read as ? 0 ?), or left unprogrammed (read as ? 1 ?) to select various device configurations as shown in register 16-1. these bits are mapped in program memory location 2007h. note: address 2007h is beyond the user program memory space. it belongs to the special configuration memory space (2000h-3fffh), which can be accessed only during programming. see ? pic16f91x/946 memory programming specification? (ds41244) for more information. register 16-1: conf ig1: config uration word register 1 ? ? ? debug fcmen ieso boren1 boren0 bit 15 bit 8 cpd cp mclre pwrte wdte fosc2 fosc1 fosc0 bit 7 bit 0 bit 15-13 unimplemented : read as ? 1 ? bit 12 debug : in-circuit debugger mode bit 1 = in-circuit debugger disabled, rb6/icspclk and rb7/icspdat are general purpose i/o pins 0 = in-circuit debugger enabled, rb6/icspclk and rb7/icspdat are dedicated to the debugger bit 11 fcmen: fail-safe clock monitor enabled bit 1 = fail-safe clock monitor is enabled 0 = fail-safe clock monitor is disabled bit 10 ieso: internal external switchover bit 1 = internal/external switchover mode is enabled 0 = internal/external switchover mode is disabled bit 9-8 boren<1:0>: brown-out reset selection bits (1) 11 = bor enabled 10 = bor enabled during operation and disabled in sleep 01 = bor controlled by sboren bit of the pcon register 00 = bor disabled bit 7 cpd : data code protection bit (2) 1 = data memory code protection is disabled 0 = data memory code protection is enabled bit 6 cp : code protection bit (3) 1 = program memory code protection is disabled 0 = program memory code protection is enabled bit 5 mclre: re3/mclr pin function select bit (4) 1 = re3/mclr pin function is mclr 0 = re3/mclr pin function is digital input, mclr internally tied to v dd bit 4 pwrte : power-up timer enable bit 1 = pwrt disabled 0 = pwrt enabled bit 3 wdte: watchdog timer enable bit 1 = wdt enabled 0 = wdt disabled and can be enabled by swdten bit of the wdtcon register bit 2-0 fosc<2:0>: oscillator selection bits 111 = rc oscillator: clkout function on ra6/osc2/clkout/t1oso pin, rc on ra7/osc1/clkin/t1osi 110 = rcio oscillator: i/o function on ra6/osc2/clkout/t1oso pin, rc on ra7/osc1/clkin/t1osi 101 = intosc oscillator: clkout function on ra6/osc2/clkout/t1oso pin, i/o function on ra7/osc1/clkin/t1osi 100 = intoscio oscillator: i/o function on ra6/osc2/clkout/ t1oso pin, i/o function on ra7/osc1/clkin/t1osi 011 = ec: i/o function on ra6/osc2/clkout/t1oso pin, clkin on ra7/osc1/clkin/t1osi 010 = hs oscillator: high-speed crystal/resonator on ra6/osc2/clkout/t1oso and ra7/osc1/clkin/t1osi 001 = xt oscillator: crystal/resonator on ra6 /osc2/clkout/t1oso and ra7/osc1/clkin/t1osi 000 = lp oscillator: low-power crystal on ra6/osc2/clkout/t1oso and ra7/osc1/clkin/t1osi note 1: enabling brown-out reset does not automatically enable power-up timer. 2: the entire data eeprom will be erased when the code protection is turned off. 3: the entire program memory will be erased when the code protection is turned off. 4: when mclr is asserted in intosc or rc mode, the internal clock oscillator is disabled.
? 2007 microchip technology inc. ds41250f-page 221 pic16f913/914/916/917/946 16.2 resets the pic16f91x/946 differentiates between various kinds of reset: a) power-on reset (por) b) wdt reset during normal operation c) wdt reset during sleep d) mclr reset during normal operation e) mclr reset during sleep f) brown-out reset (bor) some registers are not affected in any reset condition; their status is unknown on por and unchanged in any other reset. most other registers are reset to a ?reset state? on: ? power-on reset ?mclr reset ?mclr reset during sleep ?wdt reset ? brown-out reset (bor) they are not affected by a wdt wake-up since this is viewed as the resumption of normal operation. to and pd bits are set or cleared differently in different reset situations, as indicated in table 16-2. these bits are used in software to determine the nature of the reset. see table 16-5 for a full description of reset states of all registers. a simplified block diagram of the on-chip reset circuit is shown in figure 16-1. the mclr reset path has a noise filter to detect and ignore small pulses. see section 19.0 ?electrical specifications? for pulse width specifications. figure 16-1: simplified block di agram of on-chip reset circuit s r q external reset mclr /v pp pin v dd osc1/ wdt module v dd rise detect ost/pwrt lfintosc wdt time-out power-on reset ost 10-bit ripple counter pwrt chip_reset 11-bit ripple counter reset enable ost enable pwrt s leep brown-out (1) reset sboren boren clkin pin note 1: refer to the configuration word register (register 16-1).
pic16f913/914/916/917/946 ds41250f-page 222 ? 2007 microchip technology inc. 16.2.1 power-on reset (por) the on-chip por circuit holds the chip in reset until v dd has reached a high enough level for proper operation. to take advantage of the por, simply connect the mclr pin through a resistor to v dd . this will eliminate external rc components usually needed to create power-on reset. a maximum rise time for v dd is required. see section 19.0 ?electrical specifications? for details. if the bor is enabled, the maximum rise time specification does not apply. the bor circuitry will keep the device in reset until v dd reaches v bor (see section 16.2.4 ?brown-out reset (bor)? ). when the device starts normal operation (exits the reset condition), device operating parameters (i.e., voltage, frequency, temperature, etc.) must be met to ensure operation. if these conditions are not met, the device must be held in reset until the operating conditions are met. for additional information, refer to application note an607, ?power-up trouble shooting? (ds00607). 16.2.2 mclr pic16f91x/946 has a noise filter in the mclr reset path. the filter will detect and ignore small pulses. it should be noted that a wdt reset does not drive mclr pin low. voltages applied to the pin that exceed its specification can result in both mclr resets and excessive current beyond the device specification during the esd event. for this reason, microchip recommends that the mclr pin no longer be tied directly to v dd . the use of an rc network, as shown in figure 16-2, is suggested. an internal mclr option is enabled by clearing the mclre bit in the configuration word register. when mclre = 0 , the reset signal to the chip is generated internally. when the mclre = 1 , the re3/mclr pin becomes an external reset input. in this mode, the re3/mclr pin has a weak pull-up to v dd . in-circuit serial programming is not affected by selecting the internal mclr option. figure 16-2: recommended mclr circuit 16.2.3 power-up timer (pwrt) the power-up timer provides a fixed 64 ms (nominal) time-out on power-up only, from por or brown-out reset. the power-up timer operates from the 31 khz lfintosc oscillator. for more information, see section 4.5 ?internal clock modes? . the chip is kept in reset as long as pwrt is active. the pwrt delay allows the v dd to rise to an acceptable level. a config- uration bit, pwrte , can disable (if set) or enable (if cleared or programmed) the power-up timer. the power-up timer should be enabled when brown-out reset is enabled, although it is not required. the power-up timer delay will vary from chip-to-chip and vary due to: ?v dd variation ? temperature variation ? process variation see dc parameters for details ( section 19.0 ?electrical specifications? ). note: the por circuit does not produce an internal reset when v dd declines. to re-enable the por, v dd must reach vss for a minimum of 100 s. v dd pic ? mcu mclr r1 1k ( or greater) c1 0.1 f (optional, not critical)
? 2007 microchip technology inc. ds41250f-page 223 pic16f913/914/916/917/946 16.2.4 brown-out reset (bor) the boren0 and boren1 bits in the configuration word register selects one of four bor modes. two modes have been added to allow software or hardware control of the bor enable. when boren<1:0> = 01 , the sboren bit of the pcon register enables/disables the bor allowing it to be controlled in software. by selecting boren<1:0>, the bor is automatically dis- abled in sleep to conserve power and enabled on wake-up. in this mode, the sboren bit is disabled. see register 16-1 for the configuration word defini- tion. if v dd falls below v bor for greater than parameter (t bor ) (see section 19.0 ?electrical specifica- tions? ), the brown-out situation will reset the device. this will occur regardless of v dd slew rate. a reset is not insured to occur if v dd falls below v bor for less than parameter (t bor ). on any reset (power-on, brown-out reset, watchdog timer, etc.), the chip will remain in reset until v dd rises above v bor (see figure 16-3). the power-up timer will now be invoked, if enabled and will keep the chip in reset an additional 64 ms. if v dd drops below v bor while the power-up timer is running, the chip will go back into a brown-out reset and the power-up timer will be re-initialized. once v dd rises above v bor , the power-up timer will execute a 64 ms reset. 16.2.5 bor calibration the pic16f91x/946 stores the bor calibration values in fuses located in the calibration word (2008h). the calibration word is not erased when using the specified bulk erase sequence in the ? pic16f91x/946 memory programming specification? (ds41244) and thus, does not require reprogramming. figure 16-3: brown -out situations note: the power-up timer is enabled by the pwrte bit in the configuration word. address 2008h is beyond the user program memory space. it belongs to the special configuration memory space (2000h-3fffh), which can be accessed only during programming. see ? pic16f91x/946 memory programming specification? (ds41244) for more information. 64 ms (1) v bor v dd internal reset v bor v dd internal reset 64 ms (1) < 64 ms 64 ms (1) v bor v dd internal reset note 1: 64 ms delay only if pwrte bit is programmed to ? 0 ?.
pic16f913/914/916/917/946 ds41250f-page 224 ? 2007 microchip technology inc. 16.2.6 time-out sequence on power-up, the time-out sequence is as follows: first, pwrt time-out is invoked after por has expired, then ost is activated after the pwrt time-out has expired. the total time-out will vary based on oscillator configu- ration and pwrte bit status. for example, in ec mode with pwrte bit erased (pwrt disabled), there will be no time-out at all. figure 16-4, figure 16-5 and figure 16-6 depict time-out sequences. the device can exe- cute code from the intosc while ost is active, by enabling two-speed start-up or fail-safe monitor (see section 4.7.2 ?two-speed start-up sequence? and section 4.8 ?fail-safe clock monitor? ). since the time-outs occur from the por pulse, if mclr is kept low long enough, the time-outs will expire. then, bringing mclr high will begin execution immediately (see figure 16-5). this is useful for testing purposes or to synchronize more than one pic16f91x/946 device operating in parallel. table 16-5 shows the reset conditions for some special registers, while table 16-5 shows the reset conditions for all the registers. 16.2.7 power co ntrol (pcon) register the power control (pcon) register (address 8eh) has two status bits to indicate what type of reset that last occurred. bit 0 is bor (brown-out reset). bor is unknown on power-on reset. it must then be set by the user and checked on subsequent resets to see if bor = 0 , indicating that a brown-out has occurred. the bor status bit is a ?don?t care? and is not necessarily predictable if the brown-out circuit is disabled (boren<1:0> = 00 in the configuration word register). bit 1 is por (power-on reset). it is a ? 0 ? on power-on reset and unaffected otherwise. the user must write a ? 1 ? to this bit following a power-on reset. on a subsequent reset, if por is ? 0 ?, it will indicate that a power-on reset has occurred (i.e., v dd may have gone too low). for more information, see section 16.2.4 ?brown-out reset (bor)? . table 16-1: time-out in various situations table 16-2: pcon bits and their significance table 16-3: summary of registers associated with brown-out oscillator configuration power-up brown-out reset wake-up from sleep pwrte = 0 pwrte = 1 pwrte = 0 pwrte = 1 xt, hs, lp (1) t pwrt + 1024 ? t osc 1024 ? t osc t pwrt + 1024 ? t osc 1024 ? t osc 1024 ? t osc rc, ec, intosc t pwrt ?t pwrt ?? note 1: lp mode with t1osc disabled. por bor to pd condition 0u11 power-on reset 1011 brown-out reset uu0u wdt reset uu00 wdt wake-up uuuu mclr reset during normal operation uu10 mclr reset during sleep legend: u = unchanged, x = unknown name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets (1) status irp rp1 rp0 to pd z dc c 0001 1xxx 000q quuu pcon ? ? ? sboren ? ?por bor --01 --qq --0u --uu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?, q = value depends on condition. shaded cells are not used by bor. note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation.
? 2007 microchip technology inc. ds41250f-page 225 pic16f913/914/916/917/946 figure 16-4: time-out sequence on power-up (delayed mclr ): case 1 figure 16-5: time-out sequence on power-up (delayed mclr ): case 2 figure 16-6: time-out sequ ence on power-up (mclr with v dd ): case 3 t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset v dd mclr internal por pwrt time-out ost time-out internal reset t pwrt t ost t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset
pic16f913/914/916/917/946 ds41250f-page 226 ? 2007 microchip technology inc. table 16-4: initialization condition for registers register address power-on reset ? mclr reset ? wdt reset ? brown-out reset (1) ? wake-up from sleep through interrupt ? wake-up from sleep through wdt time-out w? xxxx xxxx uuuu uuuu uuuu uuuu indf 00h/80h/ 100h/180h xxxx xxxx xxxx xxxx uuuu uuuu tmr0 01h/101h xxxx xxxx uuuu uuuu uuuu uuuu pcl 02h/82h/ 102h/182h 0000 0000 0000 0000 pc + 1 (3) status 03h/83h/ 103h/183h 0001 1xxx 000q quuu (4) uuuq quuu (4) fsr 04h/84h/ 104h/184h xxxx xxxx uuuu uuuu uuuu uuuu porta 05h xxxx xxxx xxxx xxxx uuuu uuuu portb 06h/106h xxxx xxxx xxxx xxxx uuuu uuuu portc 07h xxxx xxxx xxxx xxxx uuuu uuuu portd (6) 08h xxxx xxxx xxxx xxxx uuuu uuuu porte 09h ---- xxxx xxxx xxxx (7) ---- xxxx xxxx xxxx (7) ---- uuuu uuuu uuuu (7) pclath 0ah/8ah/ 10ah/18ah ---0 0000 ---0 0000 ---u uuuu intcon 0bh/8bh/ 10bh/18bh 0000 000x 0000 000x uuuu uuuu (2) pir1 0ch 0000 0000 0000 0000 uuuu uuuu (2) pir2 0dh 0000 -0-0 0000 -0-0 uuuu -u-u tmr1l 0eh xxxx xxxx uuuu uuuu uuuu uuuu tmr1h 0fh xxxx xxxx uuuu uuuu uuuu uuuu t1con 10h 0000 0000 uuuu uuuu uuuu uuuu tmr2 11h 0000 0000 0000 0000 uuuu uuuu t2con 12h -000 0000 -000 0000 -uuu uuuu sspbuf 13h xxxx xxxx xxxx xxxx uuuu uuuu sspcon 14h 0000 0000 0000 0000 uuuu uuuu ccpr1l 15h xxxx xxxx xxxx xxxx uuuu uuuu ccpr1h 16h xxxx xxxx xxxx xxxx uuuu uuuu ccp1con 17h --00 0000 --00 0000 --uu uuuu rcsta 18h ---0 1000 ---0 1000 ---u uuuu txreg 19h 0000 0000 0000 0000 uuuu uuuu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?, q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affected differently. 2: one or more bits in intcon and/or pir1 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 16-5 for reset value for specific condition. 5: if reset was due to brown-out, then bit 0 = 0 . all other resets will cause bit 0 = u . 6: pic16F914/917 and pic16f946 only. 7: pic16f946 only.
? 2007 microchip technology inc. ds41250f-page 227 pic16f913/914/916/917/946 rcreg 1ah 0000 0000 0000 0000 uuuu uuuu ccpr2l (6) 1bh xxxx xxxx xxxx xxxx uuuu uuuu ccpr2h (6) 1ch xxxx xxxx xxxx xxxx uuuu uuuu ccp2con (6) 1dh --00 0000 --00 0000 --uu uuuu adresh 1eh xxxx xxxx uuuu uuuu uuuu uuuu adcon0 1fh 0000 0000 0000 0000 uuuu uuuu option_reg 81h/181h 1111 1111 1111 1111 uuuu uuuu trisa 85h 1111 1111 1111 1111 uuuu uuuu trisb 86h/186h 1111 1111 1111 1111 uuuu uuuu trisc 87h 1111 1111 1111 1111 uuuu uuuu trisd (6) 88h 1111 1111 1111 1111 uuuu uuuu trise 89h ---- 1111 1111 1111 (7) ---- 1111 1111 1111 (7) ---- uuuu uuuu uuuu (7) pie1 8ch 0000 0000 0000 0000 uuuu uuuu pie2 8dh 0000 -0-0 0000 -0-0 uuuu -u-u pcon 8eh --01 --0x --0u --uu (1,5) --uu --uu osccon 8fh -110 q000 -110 x000 -uuu uuuu osctune 90h ---0 0000 ---u uuuu ---u uuuu ansel 91h 1111 1111 1111 1111 uuuu uuuu pr2 92h 1111 1111 1111 1111 1111 1111 sspadd 93h 0000 0000 0000 0000 uuuu uuuu sspstat 94h 0000 0000 0000 0000 uuuu uuuu wpub 95h 1111 1111 1111 1111 uuuu uuuu iocb 96h 0000 ---- 0000 ---- uuuu ---- cmcon1 97h ---- --10 ---- --10 ---- --uu txsta 98h 0000 -010 0000 -010 uuuu -uuu spbrg 99h 0000 0000 0000 0000 uuuu uuuu cmcon0 9ch 0000 0000 0000 0000 uuuu uuuu vrcon 9dh 0-0- 0000 0-0- 0000 u-u- uuuu adresl 9eh xxxx xxxx uuuu uuuu uuuu uuuu adcon1 9fh -000 ---- -000 ---- -uuu ---- wdtcon 105h ---0 1000 ---0 1000 ---u uuuu lcdcon 107h 0001 0011 0001 0011 uuuu uuuu lcdps 108h 0000 0000 0000 0000 uuuu uuuu table 16-4: initialization conditi on for registers (continued) register address power-on reset ? mclr reset ? wdt reset ? brown-out reset (1) ? wake-up from sleep through interrupt ? wake-up from sleep through wdt time-out legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?, q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affected differently. 2: one or more bits in intcon and/or pir1 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 16-5 for reset value for specific condition. 5: if reset was due to brown-out, then bit 0 = 0 . all other resets will cause bit 0 = u . 6: pic16F914/917 and pic16f946 only. 7: pic16f946 only.
pic16f913/914/916/917/946 ds41250f-page 228 ? 2007 microchip technology inc. lvdcon 109h --00 -100 --00 -100 --uu -uuu eedatl 10ch 0000 0000 0000 0000 uuuu uuuu eeadrl 10dh 0000 0000 0000 0000 uuuu uuuu eedath 10eh --00 0000 0000 0000 uuuu uuuu eeadrh 10fh ---0 0000 0000 0000 uuuu uuuu lcddata0 110h xxxx xxxx uuuu uuuu uuuu uuuu lcddata1 111h xxxx xxxx uuuu uuuu uuuu uuuu lcddata2 (6) 112h xxxx xxxx uuuu uuuu uuuu uuuu lcddata3 113h xxxx xxxx uuuu uuuu uuuu uuuu lcddata4 114h xxxx xxxx uuuu uuuu uuuu uuuu lcddata5 (6) 115h xxxx xxxx uuuu uuuu uuuu uuuu lcddata6 116h xxxx xxxx uuuu uuuu uuuu uuuu lcddata7 117h xxxx xxxx uuuu uuuu uuuu uuuu lcddata8 (6) 118h xxxx xxxx uuuu uuuu uuuu uuuu lcddata9 119h xxxx xxxx uuuu uuuu uuuu uuuu lcddata10 11ah xxxx xxxx uuuu uuuu uuuu uuuu lcddata11 (6) 11bh xxxx xxxx uuuu uuuu uuuu uuuu lcdse0 11ch 0000 0000 uuuu uuuu uuuu uuuu lcdse1 11dh 0000 0000 uuuu uuuu uuuu uuuu lcdse2 (6) 11eh 0000 0000 uuuu uuuu uuuu uuuu trisf (7) 185h 1111 1111 1111 1111 uuuu uuuu trisg (7) 187h --11 1111 --11 1111 --uu uuuu portf (7) 188h xxxx xxxx 0000 0000 uuuu uuuu portg (7) 189h --xx xxxx --00 0000 --uu uuuu lcddata12 (7) 190h xxxx xxxx uuuu uuuu uuuu uuuu lcddata13 (7) 191h xxxx xxxx uuuu uuuu uuuu uuuu lcddata14 (7) 192h ---- --xx ---- --uu ---- --uu lcddata15 (7) 193h xxxx xxxx uuuu uuuu uuuu uuuu lcddata16 (7) 194h xxxx xxxx uuuu uuuu uuuu uuuu lcddata17 (7) 195h ---- --xx ---- --uu ---- --uu lcddata18 (7) 196h xxxx xxxx uuuu uuuu uuuu uuuu lcddata19 (7) 197h xxxx xxxx uuuu uuuu uuuu uuuu lcddata20 (7) 198h ---- --xx ---- --uu ---- --uu lcddata21 (7) 199h xxxx xxxx uuuu uuuu uuuu uuuu table 16-4: initialization conditi on for registers (continued) register address power-on reset ? mclr reset ? wdt reset ? brown-out reset (1) ? wake-up from sleep through interrupt ? wake-up from sleep through wdt time-out legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?, q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affected differently. 2: one or more bits in intcon and/or pir1 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 16-5 for reset value for specific condition. 5: if reset was due to brown-out, then bit 0 = 0 . all other resets will cause bit 0 = u . 6: pic16F914/917 and pic16f946 only. 7: pic16f946 only.
? 2007 microchip technology inc. ds41250f-page 229 pic16f913/914/916/917/946 table 16-5: initialization condition for special registers lcddata22 (7) 19ah xxxx xxxx uuuu uuuu uuuu uuuu lcddata23 (7) 19bh ---- --xx ---- --uu ---- --uu lcdse3 (7) 19ch 0000 0000 uuuu uuuu uuuu uuuu lcdse4 (7) 19dh 0000 0000 uuuu uuuu uuuu uuuu lcdse5 (7) 19eh ---- --00 ---- --uu ---- --uu eecon1 18ch x--- x000 u--- q000 u--- uuuu table 16-4: initialization conditi on for registers (continued) register address power-on reset ? mclr reset ? wdt reset ? brown-out reset (1) ? wake-up from sleep through interrupt ? wake-up from sleep through wdt time-out legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?, q = value depends on condition. note 1: if v dd goes too low, power-on reset will be activated and registers will be affected differently. 2: one or more bits in intcon and/or pir1 will be affected (to cause wake-up). 3: when the wake-up is due to an interrupt and the gie bit is set, the pc is loaded with the interrupt vector (0004h). 4: see table 16-5 for reset value for specific condition. 5: if reset was due to brown-out, then bit 0 = 0 . all other resets will cause bit 0 = u . 6: pic16F914/917 and pic16f946 only. 7: pic16f946 only. condition program counter status register pcon register power-on reset 0000h 0001 1xxx ---1 --0x mclr reset during normal operation 0000h 000u uuuu ---u --uu mclr reset during sleep 0000h 0001 0uuu ---u --uu wdt reset 0000h 0000 uuuu ---u --uu wdt wake-up pc + 1 uuu0 0uuu ---u --uu brown-out reset 0000h 0001 1uuu ---1 --10 interrupt wake-up from sleep pc + 1 (1) uuu1 0uuu ---u --uu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?. note 1: when the wake-up is due to an interrupt and global interrupt enable bit, gie, is set, the pc is loaded with the interrupt vector (0004h) after execution of pc + 1.
pic16f913/914/916/917/946 ds41250f-page 230 ? 2007 microchip technology inc. 16.3 interrupts the pic16f91x/946 has multiple sources of interrupt: ? external interrupt rb0/int/seg0 ? tmr0 overflow interrupt ? portb change interrupts ? 2 comparator interrupts ? a/d interrupt ? timer1 overflow interrupt ? eeprom data write interrupt ? fail-safe clock monitor interrupt ? lcd interrupt ? plvd interrupt ? usart receive and transmit interrupts ? ccp1 and ccp2 interrupts ? timer2 interrupt the interrupt control (intcon), peripheral interrupt request 1 (pir1) and peripheral interrupt request 2 (pir2) registers record individual interrupt requests in flag bits. the intcon register also has individual and global interrupt enable bits. a global interrupt enable bit, gie of the intcon register, enables (if set) all unmasked interrupts, or disables (if cleared) all interrupts. individual interrupts can be disabled through their corresponding enable bits in the intcon, pie1 and pie2 registers. gie is cleared on reset. the return from interrupt instruction, retfie , exits the interrupt routine, as well as sets the gie bit, which re-enables unmasked interrupts. the following interrupt flags are contained in the intcon register: ? int pin interrupt ? portb change interrupt ? tmr0 overflow interrupt the peripheral interrupt flags are contained in the special registers, pir1 and pir2. the corresponding interrupt enable bit are contained in the special registers, pie1 and pie2. the following interrupt flags are contained in the pir1 register: ? eeprom data write interrupt ? a/d interrupt ? usart receive and transmit interrupts ? timer1 overflow interrupt ? ccp1 interrupt ? ssp interrupt ? timer2 interrupt the following interrupt flags are contained in the pir2 register: ? fail-safe clock monitor interrupt ? comparator 1 and 2 interrupts ? lcd interrupt ? plvd interrupt ? ccp2 interrupt when an interrupt is serviced: ? the gie is cleared to disable any further interrupt. ? the return address is pushed onto the stack. ? the pc is loaded with 0004h. for external interrupt events, such as the int pin or portb change interrupt, the interrupt latency will be three or four instruction cycles. the exact latency depends upon when the interrupt event occurs (see figure 16-8). the latency is the same for one or two-cycle instructions. once in the interrupt service routine, the source(s) of the interrupt can be deter- mined by polling the interrupt flag bits. the interrupt flag bit(s) must be cleared in software before re-enabling interrupts to avoid multiple interrupt requests. for additional information on how a module generates an interrupt, refer to the respective peripheral section. note 1: individual interrupt flag bits are set, regardless of the status of their corresponding mask bit or the gie bit. 2: when an instruction that clears the gie bit is executed, any interrupts that were pending for execution in the next cycle are ignored. the interrupts, which were ignored, are still pending to be serviced when the gie bit is set again. note: the ansel and cmcon0 registers must be initialized to configure an analog chan- nel as a digital input. pins configured as analog inputs will read ? 0 ?. also, if a lcd output function is active on an external interrupt pin, that interrupt function will be disabled.
? 2007 microchip technology inc. ds41250f-page 231 pic16f913/914/916/917/946 16.3.1 rb0/int/seg0 interrupt external interrupt on rb0/int/seg0 pin is edge-trig- gered; either rising if the intedg bit of the option register is set, or falling, if the intedg bit is clear. when a valid edge appears on the rb0/int/seg0 pin, the intf bit of the intcon register is set. this inter- rupt can be disabled by clearing the inte control bit of the intcon register. the intf bit must be cleared in software in the interrupt service routine before re-enabling this interrupt. the rb0/int/seg0 interrupt can wake-up the processor from sleep if the inte bit was set prior to going into sleep. the status of the gie bit decides whether or not the processor branches to the interrupt vector following wake-up (0004h). see section 16.5 ?power-down mode (sleep)? for details on sleep and figure 16-10 for timing of wake-up from sleep through rb0/int/seg0 interrupt. 16.3.2 tmr0 interrupt an overflow (ffh 00h) in the tmr0 register will set the t0if bit of the intcon register. the interrupt can be enabled/disabled by setting/clearing t0ie bit of the intcon register. see section 5.0 ?timer0 module? for operation of the timer0 module. 16.3.3 portb interrupt an input change on portb change sets the rbif bit of the intcon register. the interrupt can be enabled/disabled by setting/clearing the rbie bit of the intcon register. plus, individual pins can be configured through the iocb register. figure 16-7: interrupt logic note: if a change on the i/o pin should occur when the read operation is being executed (start of the q2 cycle), then the rbif interrupt flag may not get set. tmr1if tmr1ie c1if c1ie tmr0if tmr0ie intf inte rbif rbie gie peie wake-up (if in sleep mode) interrupt to cpu peif eeie eeif adif adie ioc-rb4 iocb4 ioc-rb5 iocb5 ioc-rb6 iocb6 ioc-rb7 iocb7 ccp2if ccp2ie osfif osfie c2if c2ie ccp1if ccp1ie * sspie sspif rcif rcie txif txie lcdif lcdie lvdif lvdie tmr2if tmr2ie * only available on the pic16F914/917.
pic16f913/914/916/917/946 ds41250f-page 232 ? 2007 microchip technology inc. figure 16-8: int pin interrupt timing table 16-6: summary of interrupt registers name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor value on all other resets intcon gie peie t0ie inte rbie t0if intf rbif 0000 000x 0000 000x pir1 eeif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 pir2 osfif c2if c1if lcdif ?lvdif ?ccp2if 0000 -0-0 0000 -0-0 pie1 eeie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 pie2 osfie c2ie c1ie lcdie ?lvdie ? ccp2ie 0000 -0-0 0000 -0-0 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by the interrupt module. q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 osc1 clkout (3) int pin intf flag (intcon reg.) gie bit (intcon reg.) instruction flow pc instruction fetched instruction executed interrupt latency pc pc + 1 pc + 1 0004h 0005h inst (0004h) inst (0005h) dummy cycle inst (pc) inst (pc + 1) inst (pc - 1) inst (0004h) dummy cycle inst (pc) ? note 1: intf flag is sampled here (every q1). 2: asynchronous interrupt latency = 3-4 t cy . synchronous latency = 3 t cy , where t cy = instruction cycle time. latency is the same whether inst (pc) is a single cycle or a 2-cycle instruction. 3: clkout is available only in intosc and rc oscillator modes. 4: for minimum width of int pulse, refer to ac specifications in section 19.0 ?electrical specifications? . 5: intf is enabled to be set any time during the q4-q1 cycles. (1) (2) (4) (5) (1)
? 2007 microchip technology inc. ds41250f-page 233 pic16f913/914/916/917/946 16.3.4 context saving during interrupts during an interrupt, only the return pc value is saved on the stack. typically, users may wish to save key registers during an interrupt (e.g., w and status registers). this must be implemented in software. since the lower 16 bytes of all banks are common in the pic16f91x/946 (see figure 2-3), temporary holding registers, w_temp and status_temp, should be placed in here. these 16 locations do not require banking and therefore, make it easier to context save and restore. the same code shown in example 16-1 can be used to: ? store the w register ? store the status register ? execute the isr code ? restore the status register (bank select bits) ? restore the w register example 16-1: saving status and w registers in ram note: the microcontroller does not normally require saving the pclath register unless it is modified in code either directly or via the pagesel macro. then, the pclath register must be saved at the beginning of the isr, managed for call s and goto s in the isr and restored when the isr is complete to ensure correct program flow. movwf w_temp ;copy w to temp register swapf status,w ;swap status to be saved into w clrf status ;bank 0, regardless of current bank, clears irp,rp1,rp0 movwf status_temp ;save status to bank zero status_temp register : :(isr) ;insert user code here : swapf status_temp,w ;swap status_temp register into w ;(sets bank to original state) movwf status ;move w into status register swapf w_temp,f ;swap w_temp swapf w_temp,w ;swap w_temp into w
pic16f913/914/916/917/946 ds41250f-page 234 ? 2007 microchip technology inc. 16.4 watchdog timer (wdt) for pic16f91x/946, the wdt has been modified from previous pic16f devices. the new wdt is code and functionally compatible with previous pic16f wdt modules and adds a 16-bit prescaler to the wdt. this allows the user to have a scaled value for the wdt and tmr0 at the same time. in addition, the wdt time-out value can be extended to 268 seconds. wdt is cleared under certain conditions described in table 16-7. 16.4.1 wdt oscillator the wdt derives its time base from the 31 khz lfintosc. the lts bit does not reflect that the lfintosc is enabled. the value of wdtcon is ?---0 1000? on all resets. this gives a nominal time base of 16 ms, which is compatible with the time base generated with previous pic16f microcontroller versions. a new prescaler has been added to the path between the intosc and the multiplexers used to select the path for the wdt. this prescaler is 16 bits and can be programmed to divide the intosc by 32 to 65536, giving the wdt a nominal range of 1 ms to 268s. 16.4.2 wdt control the wdte bit is located in the configuration word register. when set, the wdt runs continuously. when the wdte bit in the configuration word register is set, the swdten bit of the wdtcon register has no effect. if wdte is clear, then the swdten bit can be used to enable and disable the wdt. setting the bit will enable it and clearing the bit will disable it. the psa and ps<2:0> bits of the option register have the same function as in previous versions of the pic16f family of microcontrollers. see section 5.0 ?timer0 module? for more information. figure 16-9: watchdog timer block diagram note: when the oscillator start-up timer (ost) is invoked, the wdt is held in reset, because the wdt ripple counter is used by the ost to perform the oscillator delay count. when the ost count has expired, the wdt will begin counting (if enabled). table 16-7: wdt status conditions wdt wdte = 0 cleared clrwdt command oscillator fail detected exit sleep + system clock = t1osc, extrc, intosc, extclk exit sleep + system clock = xt, hs, lp cleared until the end of ost 31 khz psa 16-bit wdt prescaler from tmr0 clock source prescaler (1) 8 ps<2:0> psa wdt time-out to t m r 0 wdtps<3:0> wdte from configuration word register 1 1 0 0 swdten from wdtcon lfintosc clock note 1 : this is the shared timer0/wdt prescaler. see section 5.4 ?prescaler? for more information.
? 2007 microchip technology inc. ds41250f-page 235 pic16f913/914/916/917/946 register 16-2: wdtcon ? watchdog timer control regi ster (address: 105h) table 16-8: summary of watchdog timer registers u-0 u-0 u-0 r/w-0 r/w-1 r/w-0 r/w-0 r/w-0 ? ? ? wdtps3 wdtps2 wdtps1 wdtps0 swdten bit 7 bit 0 bit 7-5 unimplemented: read as ? 0 ? bit 4-1 wdtps<3:0>: watchdog timer period select bits bit value = prescale rate 0000 = 1:32 0001 = 1:64 0010 = 1:128 0011 = 1:256 0100 = 1:512 (reset value) 0101 = 1:1024 0110 = 1:2048 0111 = 1:4096 1000 = 1:8192 1001 = 1:16384 1010 = 1:32768 1011 = 1:65536 1100 = reserved 1101 = reserved 1110 = reserved 1111 = reserved bit 0 swdten: software enable or disable the watchdog timer bit (1) 1 = wdt is turned on 0 = wdt is turned off (reset value) note 1: if wdte configuration bit = 1 , then wdt is always enabled, irrespective of this control bit. if wdte configuration bit = 0 , then it is possible to turn wdt on/off with this control bit. legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? - n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 config cpd cp mclre pwrte wdte fosc2 fosc1 fosc0 option_reg rbpu intedg t0cs t0se psa ps2 ps1 ps0 wdtcon ? ? ? wdtps3 wdtps2 wstps1 wdtps0 swdten legend: shaded cells are not used by the watchdog timer. note 1: see register 16-1 for operation of all configuration word register bits.
pic16f913/914/916/917/946 ds41250f-page 236 ? 2007 microchip technology inc. 16.5 power-down mode (sleep) the power-down mode is entered by executing a sleep instruction. if the watchdog timer is enabled: ? wdt will be cleared but keeps running. ?pd bit in the status register is cleared. ?to bit is set. ? oscillator driver is turned off. ? timer1 oscillator is unaffected ? i/o ports maintain the status they had before sleep was executed (driving high, low or high-impedance). for lowest current consumption in this mode, all i/o pins should be either at v dd or v ss , with no external circuitry drawing current from the i/o pin, and the comparators and cv ref should be disabled. i/o pins that are high-impedance inputs should be pulled high or low externally to avoid switching currents caused by floating inputs. the t0cki input should also be at v dd or v ss for lowest current consumption. the contribution from on-chip pull-ups on portb should be considered. the mclr pin must be at a logic high level. 16.5.1 wake-up from sleep the device can wake-up from sleep through one of the following events: 1. external reset input on mclr pin. 2. watchdog timer wake-up (if wdt was enabled). 3. interrupt from rb0/int/seg0 pin, portb change or a peripheral interrupt. the first event will cause a device reset. the two latter events are considered a continuation of program execution. the to and pd bits in the status register can be used to determine the cause of device reset. the pd bit, which is set on power-up, is cleared when sleep is invoked. to bit is cleared if wdt wake-up occurred. the following peripheral interrupts can wake the device from sleep: 1. tmr1 interrupt. timer1 must be operating as an asynchronous counter. 2. usart receive interrupt (sync slave mode only) 3. a/d conversion (when a/d clock source is rc) 4. eeprom write operation completion 5. comparator output changes state 6. interrupt-on-change 7. external interrupt from int pin 8. plvd interrupt 9. lcd interrupt (if running during sleep) other peripherals cannot generate interrupts since during sleep, no on-chip clocks are present. when the sleep instruction is being executed, the next instruction (pc + 1) is pre-fetched. for the device to wake-up through an interrupt event, the corresponding interrupt enable bit must be set (enabled). wake-up is regardless of the state of the gie bit. if the gie bit is clear (disabled), the device continues execution at the instruction after the sleep instruction. if the gie bit is set (enabled), the device executes the instruction after the sleep instruction, then branches to the interrupt address (0004h). in cases where the execution of the instruction following sleep is not desirable, the user should have a nop after the sleep instruction. the wdt is cleared when the device wakes up from sleep, regardless of the source of wake-up. 16.5.2 wake-up using interrupts when global interrupts are disabled (gie cleared) and any interrupt source has both its interrupt enable bit and interrupt flag bit set, one of the following will occur: ? if the interrupt occurs before the execution of a sleep instruction, the sleep instruction will complete as a nop . therefore, the wdt and wdt prescaler and postscaler (if enabled) will not be cleared, the to bit will not be set and the pd bit will not be cleared. ? if the interrupt occurs during or after the execution of a sleep instruction, the device will immediately wake-up from sleep. the sleep instruction will be completely executed before the wake-up. therefore, the wdt and wdt prescaler and postscaler (if enabled) will be cleared, the to bit will be set and the pd bit will be cleared. note: it should be noted that a reset generated by a wdt time-out does not drive mclr pin low. note: if the global interrupts are disabled (gie is cleared), but any interrupt source has both its interrupt enable bit and the correspond- ing interrupt flag bits set, the device will immediately wake-up from sleep. the sleep instruction is completely executed.
? 2007 microchip technology inc. ds41250f-page 237 pic16f913/914/916/917/946 even if the flag bits were checked before executing a sleep instruction, it may be possible for flag bits to become set before the sleep instruction completes. to determine whether a sleep instruction executed, test the pd bit. if the pd bit is set, the sleep instruction was executed as a nop . to ensure that the wdt is cleared, a clrwdt instruction should be executed before a sleep instruction. figure 16-10: wake-up from sleep through interrupt q1 q2 q3 q4 q1 q2 q3 q4 q1 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 (1) clkout (4) int pin intf flag (intcon reg.) gie bit (intcon reg.) instruction flow pc instruction fetched instruction executed pc pc + 1 pc + 2 inst(pc) = sleep inst(pc - 1) inst(pc + 1) sleep processor in sleep interrupt latency (3) inst(pc + 2) inst(pc + 1) inst(0004h) inst(0005h) inst(0004h) dummy cycle pc + 2 0004h 0005h dummy cycle t ost (2) pc + 2 note 1: xt, hs or lp oscillator mode assumed. 2: t ost = 1024 t osc (drawing not to scale). this delay does not apply to ec and rc oscillator modes. 3: gie = 1 assumed. in this case after wake-up, the processor jumps to 0004h. if gie = 0 , execution will continue in-line. 4: clkout is not available in xt, hs, lp or ec oscillator modes, but shown here for timing reference.
pic16f913/914/916/917/946 ds41250f-page 238 ? 2007 microchip technology inc. 16.6 code protection if the code protection bit(s) have not been programmed, the on-chip program memory can be read out using icsp for verification purposes. 16.7 id locations four memory locations (2000h-2003h) are designated as id locations where the user can store checksum or other code identification numbers. these locations are not accessible during normal execution, but are readable and writable during program/verify mode. only the least significant 7 bits of the id locations are used. 16.8 in-circuit serial programming the pic16f91x/946 microcontrollers can be serially programmed while in the end application circuit. this is simply done with two lines for clock and data and three other lines for: ? power ? ground ? programming voltage this allows customers to manufacture boards with unprogrammed devices and then program the microcontroller just before shipping the product. this also allows the most recent firmware or a custom firmware to be programmed. the device is placed into a program/verify mode by holding the rb7/icspdat/icddat/seg13 and rb6/icspclk/icdck/seg14 pins low, while raising the mclr (v pp ) pin from v il to v ihh . see ? pic16f91x/946 memory programming specification? (ds41244) for more information. rb7 becomes the programming data and the rb6 becomes the programming clock. both rb7 and rb6 are schmitt trigger inputs in this mode. after reset, to place the device into program/verify mode, the program counter (pc) is at location 0000h. a 6-bit command is then supplied to the device. depending on the command, 14 bits of program data are then supplied to or from the device, depending on whether the command was a load or a read. for complete details of serial programming, please refer to the ? pic16f91x/946 memory programming specification? (ds41244). a typical in-circuit serial programming connection is shown in figure 16-11. figure 16-11: typical in-circuit serial programming connection note: the entire data eeprom and flash program memory will be erased when the code protection is turned off. see the ? pic16f91x/946 memory programming specification? (ds41244) for more information. external connector signals to n o r m a l connections to n o rm a l connections pic ? mcu v dd v ss re3/mclr /v pp rb6/icspclk/ rb7/icspdata/ +5v 0v v pp clk data i/o * * * * * isolation devices (as required) icdck/seg14 icddat/seg13
? 2007 microchip technology inc. ds41250f-page 239 pic16f913/914/916/917/946 16.9 in-circuit debugger when the debug bit in the configuration word register is programmed to a ? 0 ?, the in-circuit debugger func- tionality is enabled. this function allows simple debug- ging functions when used with mplab ? icd 2. when the microcontroller has this feature enabled, some of the resources are not available for general use. see table 16-9 for more detail. for more information, see ? using mplab ? icd 2? (ds51265), available on microchip?s web site (www.microchip.com). 16.9.1 icd pinout the devices in the pic16f91x/946 family carry the circuitry for the in-circuit debugger on-chip and on existing device pins. this eliminates the need for a separate die or package for the icd device. the pinout for the icd device is the same as the devices (see section 1.0 ?device overview? for complete pinout and pin descriptions). table 16-9 shows the location and function of the icd related pins on the 28 and 40-pin devices. table 16-9: pic16f91x/946-icd pin descriptions note: the user?s application must have the circuitry required to support icd functionality. once the icd circuitry is enabled, normal device pin functions on rb6/icspclk/icdck/seg14 and rb7/icspdat/icddat/seg13 will not be usable. the icd circuitry uses these pins for communication with the icd2 external debugger. pin numbers name type pull-up description pdip tqfp pic16F914/917 pic16f913/916 pic16f946 40 28 24 icddata ttl ? in circuit debugger bidirectional data 39 27 23 icdclk st ? in circuit debugger bidirectional clock 1 1 36 mclr /v pp hv ? programming voltage 11,32 20 10, 19, 38, 51 v dd p?power 12,31 8,19 9, 20, 41, 56 v ss p ? ground ??26av dd p ? analog power ??25av ss p ? analog ground legend: ttl = ttl input buffer, st = schmitt trigger input buffer, p = power, hv = high voltage
pic16f913/914/916/917/946 ds41250f-page 240 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 241 pic16f913/914/916/917/946 17.0 instruction set summary the pic16f913/914/916/917/946 instruction set is highly orthogonal and is comprised of three basic cate- gories: ? byte-oriented operations ? bit-oriented operations ? literal and control operations each pic16 instruction is a 14-bit word divided into an opcode, which specifies the instruction type and one or more operands, which further specify the operation of the instruction. the formats for each of the categories is presented in figure 17-1, while the various opcode fields are summarized in table 17-1. table 17-2 lists the instructions recognized by the mpasm tm assembler. for byte-oriented instructions, ?f? represents a file register designator and ?d? represents a destination designator. the file register designator specifies which file register is to be used by the instruction. the destination designator specifies where the result of the operation is to be placed. if ?d? is zero, the result is placed in the w register. if ?d? is one, the result is placed in the file register specified in the instruction. for bit-oriented instructions, ?b? represents a bit field designator, which selects the bit affected by the operation, while ?f? represents the address of the file in which the bit is located. for literal and control operations, ?k? represents an 8-bit or 11-bit constant, or literal value. one instruction cycle consists of four oscillator periods; for an oscillator frequency of 4 mhz, this gives a nominal instruction execution time of 1 s. all instructions are executed within a single instruction cycle, unless a conditional test is true, or the program counter is changed as a result of an instruction. when this occurs, the execution takes two instruction cycles, with the second cycle executed as a nop . all instruction examples use the format ? 0xhh ? to represent a hexadecimal number, where ? h ? signifies a hexadecimal digit. 17.1 read-modify-write operations any instruction that specifies a file register as part of the instruction performs a read-modify-write (r-m-w) operation. the register is read, the data is modified, and the result is stored according to either the instruc- tion, or the destination designator ?d?. a read operation is performed on a register even if the instruction writes to that register. for example, a clrf porta instruction will read porta, clear all the data bits, then write the result back to porta. this example would have the unintended consequence of clearing the condition that set the rbif flag. table 17-1: opcode field descriptions figure 17-1: general format for instructions field description f register file address (0x00 to 0x7f) w working register (accumulator) b bit address within an 8-bit file register k literal field, constant data or label x don?t care location (= 0 or 1 ). the assembler will generate code with x = 0 . it is the recommended form of use for compatibility with all microchip software tools. d destination select; d = 0 : store result in w , d = 1 : store result in file register f. default is d = 1. pc program counter to time-out bit c carry bit dc digit carry bit z zero bit pd power-down bit byte-oriented file register operations 13 8 7 6 0 d = 0 for destination w opcode d f (file #) d = 1 for destination f f = 7-bit file register address bit-oriented file register operations 13 10 9 7 6 0 opcode b (bit #) f (file #) b = 3-bit bit address f = 7-bit file register address literal and control operations 13 8 7 0 opcode k (literal) k = 8-bit immediate value 13 11 10 0 opcode k (literal) k = 11-bit immediate value general call and goto instructions only
pic16f913/914/916/917/946 ds41250f-page 242 ? 2007 microchip technology inc. table 17-2: pic16f913/914/916/917/946 instruction set mnemonic, operands description cycles 14-bit opcode status affected notes msb lsb byte-oriented file register operations addwf andwf clrf clrw comf decf decfsz incf incfsz iorwf movf movwf nop rlf rrf subwf swapf xorwf f, d f, d f ? f, d f, d f, d f, d f, d f, d f, d f ? f, d f, d f, d f, d f, d add w and f and w with f clear f clear w complement f decrement f decrement f, skip if 0 increment f increment f, skip if 0 inclusive or w with f move f move w to f no operation rotate left f through carry rotate right f through carry subtract w from f swap nibbles in f exclusive or w with f 1 1 1 1 1 1 1 (2) 1 1 (2) 1 1 1 1 1 1 1 1 1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0111 0101 0001 0001 1001 0011 1011 1010 1111 0100 1000 0000 0000 1101 1100 0010 1110 0110 dfff dfff lfff 0xxx dfff dfff dfff dfff dfff dfff dfff lfff 0xx0 dfff dfff dfff dfff dfff ffff ffff ffff xxxx ffff ffff ffff ffff ffff ffff ffff ffff 0000 ffff ffff ffff ffff ffff c, dc, z z z z z z z z z c c c, dc, z z 1, 2 1, 2 2 1, 2 1, 2 1, 2, 3 1, 2 1, 2, 3 1, 2 1, 2 1, 2 1, 2 1, 2 1, 2 1, 2 bit-oriented file register operations bcf bsf btfsc btfss f, b f, b f, b f, b bit clear f bit set f bit test f, skip if clear bit test f, skip if set 1 1 1 (2) 1 (2) 01 01 01 01 00bb 01bb 10bb 11bb bfff bfff bfff bfff ffff ffff ffff ffff 1, 2 1, 2 3 3 literal and control operations addlw andlw call clrwdt goto iorlw movlw retfie retlw return sleep sublw xorlw k k k ? k k k ? k ? ? k k add literal and w and literal with w call subroutine clear watchdog timer go to address inclusive or literal with w move literal to w return from interrupt return with literal in w return from subroutine go into standby mode subtract w from literal exclusive or literal with w 1 1 2 1 2 1 1 2 2 2 1 1 1 11 11 10 00 10 11 11 00 11 00 00 11 11 111x 1001 0kkk 0000 1kkk 1000 00xx 0000 01xx 0000 0000 110x 1010 kkkk kkkk kkkk 0110 kkkk kkkk kkkk 0000 kkkk 0000 0110 kkkk kkkk kkkk kkkk kkkk 0100 kkkk kkkk kkkk 1001 kkkk 1000 0011 kkkk kkkk c, dc, z z to , p d z to , p d c, dc, z z note 1: when an i/o register is modified as a function of itself (e.g., movf gpio, 1 ), the value used will be that value present on the pins themselves. for example, if the data latch is ? 1 ? for a pin configured as input and is driven low by an external device, the data will be written back with a ? 0 ?. 2: if this instruction is executed on the tm r0 register (and where applicable, d = 1 ), the prescaler will be cleared if assigned to the timer0 module. 3: if the program counter (pc) is modified, or a conditional test is true, the instruction requires two cycles. the second cycle is executed as a nop .
? 2007 microchip technology inc. ds41250f-page 243 pic16f913/914/916/917/946 17.2 instruction descriptions addlw add literal and w syntax: [ label ] addlw k operands: 0 k 255 operation: (w) + k (w) status affected: c, dc, z description: the contents of the w register are added to the eight-bit literal ?k? and the result is placed in the w register. addwf add w and f syntax: [ label ] addwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) + (f) (destination) status affected: c, dc, z description: add the contents of the w register with register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?. andlw and literal with w syntax: [ label ] andlw k operands: 0 k 255 operation: (w) .and. (k) (w) status affected: z description: the contents of w register are and?ed with the eight-bit literal ?k?. the result is placed in the w register. andwf and w with f syntax: [ label ] andwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) .and. (f) (destination) status affected: z description: and the w register with register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?. bcf bit clear f syntax: [ label ] bcf f,b operands: 0 f 127 0 b 7 operation: 0 (f) status affected: none description: bit ?b? in register ?f? is cleared. bsf bit set f syntax: [ label ] bsf f,b operands: 0 f 127 0 b 7 operation: 1 (f) status affected: none description: bit ?b? in register ?f? is set. btfsc bit test f, skip if clear syntax: [ label ] btfsc f,b operands: 0 f 127 0 b 7 operation: skip if (f) = 0 status affected: none description: if bit ?b? in register ?f? is ? 1 ?, the next instruction is executed. if bit ?b?, in register ?f?, is ? 0 ?, the next instruction is discarded, and a nop is executed instead, making this a 2-cycle instruction.
pic16f913/914/916/917/946 ds41250f-page 244 ? 2007 microchip technology inc. btfss bit test f, skip if set syntax: [ label ] btfss f,b operands: 0 f 127 0 b < 7 operation: skip if (f) = 1 status affected: none description: if bit ?b? in register ?f? is ? 0 ?, the next instruction is executed. if bit ?b? is ? 1 ?, then the next instruction is discarded and a nop is executed instead, making this a 2-cycle instruction. call call subroutine syntax: [ label ] call k operands: 0 k 2047 operation: (pc)+ 1 tos, k pc<10:0>, (pclath<4:3>) pc<12:11> status affected: none description: call subroutine. first, return address (pc + 1) is pushed onto the stack. the eleven-bit immediate address is loaded into pc bits <10:0>. the upper bits of the pc are loaded from pclath. call is a two-cycle instruction. clrf clear f syntax: [ label ] clrf f operands: 0 f 127 operation: 00h (f) 1 z status affected: z description: the contents of register ?f? are cleared and the z bit is set. clrw clear w syntax: [ label ] clrw operands: none operation: 00h (w) 1 z status affected: z description: w register is cleared. zero bit (z) is set. clrwdt clear watchdog timer syntax: [ label ] clrwdt operands: none operation: 00h wdt 0 wdt prescaler, 1 to 1 pd status affected: to , pd description: clrwdt instruction resets the watchdog timer. it also resets the prescaler of the wdt. status bits to and pd are set. comf complement f syntax: [ label ] comf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f ) (destination) status affected: z description: the contents of register ?f? are complemented. if ?d? is ? 0 ?, the result is stored in w. if ?d? is ? 1 ?, the result is stored back in register ?f?. decf decrement f syntax: [ label ] decf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) - 1 (destination) status affected: z description: decrement register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?.
? 2007 microchip technology inc. ds41250f-page 245 pic16f913/914/916/917/946 decfsz decrement f, skip if 0 syntax: [ label ] decfsz f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) - 1 (destination); skip if result = 0 status affected: none description: the contents of register ?f? are decremented. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. if the result is ? 1 ?, the next instruction is executed. if the result is ? 0 ?, then a nop is executed instead, making it a 2-cycle instruction. goto unconditional branch syntax: [ label ] goto k operands: 0 k 2047 operation: k pc<10:0> pclath<4:3> pc<12:11> status affected: none description: goto is an unconditional branch. the eleven-bit immediate value is loaded into pc bits <10:0>. the upper bits of pc are loaded from pclath<4:3>. goto is a two-cycle instruction. incf increment f syntax: [ label ] incf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) + 1 (destination) status affected: z description: the contents of register ?f? are incremented. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. incfsz increment f, skip if 0 syntax: [ label ] incfsz f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) + 1 (destination), skip if result = 0 status affected: none description: the contents of register ?f? are incremented. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. if the result is ? 1 ?, the next instruction is executed. if the result is ? 0 ?, a nop is executed instead, making it a 2-cycle instruction. iorlw inclusive or literal with w syntax: [ label ] iorlw k operands: 0 k 255 operation: (w) .or. k (w) status affected: z description: the contents of the w register are or?ed with the eight-bit literal ?k?. the result is placed in the w register. iorwf inclusive or w with f syntax: [ label ] iorwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) .or. (f) (destination) status affected: z description: inclusive or the w register with register ?f?. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?.
pic16f913/914/916/917/946 ds41250f-page 246 ? 2007 microchip technology inc. movf move f syntax: [ label ] movf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) (dest) status affected: z description: the contents of register f is moved to a destination dependent upon the status of d. if d = 0 , destination is w register. if d = 1 , the destination is file register f itself. d = 1 is useful to test a file register since status flag z is affected. words: 1 cycles: 1 example: movf fsr, 0 after instruction w= value in fsr register z= 1 movlw move literal to w syntax: [ label ] movlw k operands: 0 k 255 operation: k (w) status affected: none description: the eight-bit literal ?k? is loaded into w register. the ?don?t cares? will assemble as ? 0 ?s. words: 1 cycles: 1 example: movlw 0x5a after instruction w= 0x5a movwf move w to f syntax: [ label ] movwf f operands: 0 f 127 operation: (w) (f) status affected: none description: move data from w register to register ?f?. words: 1 cycles: 1 example: movw f option before instruction option = 0xff w = 0x4f after instruction option = 0x4f w = 0x4f nop no operation syntax: [ label ] nop operands: none operation: no operation status affected: none description: no operation. words: 1 cycles: 1 example: nop
? 2007 microchip technology inc. ds41250f-page 247 pic16f913/914/916/917/946 retfie return from interrupt syntax: [ label ] retfie operands: none operation: tos pc, 1 gie status affected: none description: return from interrupt. stack is poped and top-of-stack (tos) is loaded in the pc. interrupts are enabled by setting global interrupt enable bit, gie (intcon<7>). this is a two-cycle instruction. words: 1 cycles: 2 example: retfie after interrupt pc = tos gie = 1 retlw return with literal in w syntax: [ label ] retlw k operands: 0 k 255 operation: k (w); tos pc status affected: none description: the w register is loaded with the eight bit literal ?k?. the program counter is loaded from the top of the stack (the return address). this is a two-cycle instruction. words: 1 cycles: 2 example: table call table;w contains table ;offset value ? ;w now has table value ? ? addwf pc ;w = offset retlw k1 ;begin table retlw k2 ; ? ? ? retlw kn ; end of table before instruction w = 0x07 after instruction w = value of k8 return return from subroutine syntax: [ label ] return operands: none operation: tos pc status affected: none description: return from subroutine. the stack is poped and the top of the stack (tos) is loaded into the program counter. this is a two-cycle instruction.
pic16f913/914/916/917/946 ds41250f-page 248 ? 2007 microchip technology inc. rlf rotate left f through carry syntax: [ label ] rlf f,d operands: 0 f 127 d [ 0 , 1 ] operation: see description below status affected: c description: the contents of register ?f? are rotated one bit to the left through the carry flag. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?. words: 1 cycles: 1 example: rlf reg1,0 before instruction reg1 = 1110 0110 c=0 after instruction reg1 = 1110 0110 w = 1100 1100 c=1 rrf rotate right f through carry syntax: [ label ] rrf f,d operands: 0 f 127 d [ 0 , 1 ] operation: see description below status affected: c description: the contents of register ?f? are rotated one bit to the right through the carry flag. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. register f c register f c sleep enter sleep mode syntax: [ label ] sleep operands: none operation: 00h wdt, 0 wdt prescaler, 1 to , 0 pd status affected: to , pd description: the power-down status bit, pd is cleared. time-out status bit, to is set. watchdog timer and its prescaler are cleared. the processor is put into sleep mode with the oscillator stopped. sublw subtract w from literal syntax: [ label ] sublw k operands: 0 k 255 operation: k - (w) ( w) status affected: c, dc, z description: the w register is subtracted (2?s complement method) from the eight-bit literal ?k?. the result is placed in the w register. c = 0 w > k c = 1 w k dc = 0 w<3:0> > k<3:0> dc = 1 w<3:0> k<3:0>
? 2007 microchip technology inc. ds41250f-page 249 pic16f913/914/916/917/946 subwf subtract w from f syntax: [ label ] subwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) - (w) ( destination) status affected: c, dc, z description: subtract (2?s complement method) w register from register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f. swapf swap nibbles in f syntax: [ label ] swapf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f<3:0>) (destination<7:4>), (f<7:4>) (destination<3:0>) status affected: none description: the upper and lower nibbles of register ?f? are exchanged. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed in register ?f?. c = 0 w > f c = 1 w f dc = 0 w<3:0> > f<3:0> dc = 1 w<3:0> f<3:0> xorlw exclusive or literal with w syntax: [ label ] xorlw k operands: 0 k 255 operation: (w) .xor. k ( w) status affected: z description: the contents of the w register are xor?ed with the eight-bit literal ?k?. the result is placed in the w register. xorwf exclusive or w with f syntax: [ label ] xorwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) .xor. (f) ( destination) status affected: z description: exclusive or the contents of the w register with register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?.
pic16f913/914/916/917/946 ds41250f-page 250 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 251 pic16f913/914/916/917/946 18.0 development support the pic ? microcontrollers are supported with a full range of hardware and software development tools: ? integrated development environment - mplab ? ide software ? assemblers/compilers/linkers - mpasm tm assembler - mplab c18 and mplab c30 c compilers -mplink tm object linker/ mplib tm object librarian - mplab asm30 assembler/linker/library ? simulators - mplab sim software simulator ?emulators - mplab ice 2000 in-circuit emulator - mplab real ice? in-circuit emulator ? in-circuit debugger - mplab icd 2 ? device programmers - picstart ? plus development programmer - mplab pm3 device programmer - pickit? 2 development programmer ? low-cost demonstration and development boards and evaluation kits 18.1 mplab integrated development environment software the mplab ide software brings an ease of software development previously unseen in the 8/16-bit micro- controller market. the mplab ide is a windows ? operating system-based application that contains: ? a single graphical interface to all debugging tools - simulator - programmer (sold separately) - emulator (sold separately) - in-circuit debugger (sold separately) ? a full-featured editor with color-coded context ? a multiple project manager ? customizable data windows with direct edit of contents ? high-level source code debugging ? visual device initializer for easy register initialization ? mouse over variable inspection ? drag and drop variables from source to watch windows ? extensive on-line help ? integration of select third party tools, such as hi-tech software c compilers and iar c compilers the mplab ide allows you to: ? edit your source files (either assembly or c) ? one touch assemble (or compile) and download to pic mcu emulator and simulator tools (automatically updates all project information) ? debug using: - source files (assembly or c) - mixed assembly and c - machine code mplab ide supports multiple debugging tools in a single development paradigm, from the cost-effective simulators, through low-cost in-circuit debuggers, to full-featured emulators. this eliminates the learning curve when upgrading to tools with increased flexibility and power.
pic16f913/914/916/917/946 ds41250f-page 252 ? 2007 microchip technology inc. 18.2 mpasm assembler the mpasm assembler is a full-featured, universal macro assembler for all pic mcus. the mpasm assembler generates relocatable object files for the mplink object linker, intel ? standard hex files, map files to detail memory usage and symbol reference, absolute lst files that contain source lines and generated machine code and coff files for debugging. the mpasm assembler features include: ? integration into mplab ide projects ? user-defined macros to streamline assembly code ? conditional assembly for multi-purpose source files ? directives that allow complete control over the assembly process 18.3 mplab c18 and mplab c30 c compilers the mplab c18 and mplab c30 code development systems are complete ansi c compilers for microchip?s pic18 and pic24 families of microcontrol- lers and the dspic30 and dspic33 family of digital sig- nal controllers. these compilers provide powerful integration capabilities, superior code optimization and ease of use not found with other compilers. for easy source level debugging, the compilers provide symbol information that is optimized to the mplab ide debugger. 18.4 mplink object linker/ mplib object librarian the mplink object linker combines relocatable objects created by the mpasm assembler and the mplab c18 c compiler. it can link relocatable objects from precompiled libraries, using directives from a linker script. the mplib object librarian manages the creation and modification of library files of precompiled code. when a routine from a library is called from a source file, only the modules that contain that routine will be linked in with the application. this allows large libraries to be used efficiently in many different applications. the object linker/library features include: ? efficient linking of single libraries instead of many smaller files ? enhanced code maintainability by grouping related modules together ? flexible creation of libraries with easy module listing, replacement, deletion and extraction 18.5 mplab asm30 assembler, linker and librarian mplab asm30 assembler produces relocatable machine code from symbolic assembly language for dspic30f devices. mplab c30 c compiler uses the assembler to produce its object file. the assembler generates relocatable object files that can then be archived or linked with other relocatable object files and archives to create an executable file. notable features of the assembler include: ? support for the entire dspic30f instruction set ? support for fixed-point and floating-point data ? command line interface ? rich directive set ? flexible macro language ? mplab ide compatibility 18.6 mplab sim software simulator the mplab sim software simulator allows code development in a pc-hosted environment by simulat- ing the pic mcus and dspic ? dscs on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a comprehensive stimulus controller. registers can be logged to files for further run-time analysis. the trace buffer and logic analyzer display extend the power of the simulator to record and track program execution, actions on i/o, most peripherals and internal registers. the mplab sim software simulator fully supports symbolic debugging using the mplab c18 and mplab c30 c compilers, and the mpasm and mplab asm30 assemblers. the software simulator offers the flexibility to develop and debug code outside of the hardware laboratory environment, making it an excellent, economical software development tool.
? 2007 microchip technology inc. ds41250f-page 253 pic16f913/914/916/917/946 18.7 mplab ice 2000 high-performance in-circuit emulator the mplab ice 2000 in-circuit emulator is intended to provide the product development engineer with a complete microcontroller design tool set for pic microcontrollers. software control of the mplab ice 2000 in-circuit emulator is advanced by the mplab integrated development environment, which allows editing, building, downloading and source debugging from a single environment. the mplab ice 2000 is a full-featured emulator system with enhanced trace, trigger and data monitor- ing features. interchangeable processor modules allow the system to be easily reconfigured for emulation of different processors. the architecture of the mplab ice 2000 in-circuit emulator allows expansion to support new pic microcontrollers. the mplab ice 2000 in-circuit emulator system has been designed as a real-time emulation system with advanced features that are typically found on more expensive development tools. the pc platform and microsoft ? windows ? 32-bit operating system were chosen to best make these features available in a simple, unified application. 18.8 mplab real ice in-circuit emulator system mplab real ice in-circuit emulator system is microchip?s next generation high-speed emulator for microchip flash dsc ? and mcu devices. it debugs and programs pic ? and dspic ? flash microcontrollers with the easy-to-use, powerful graphical user interface of the mplab integrated development environment (ide), included with each kit. the mplab real ice probe is connected to the design engineer?s pc using a high-speed usb 2.0 interface and is connected to the target with either a connector compatible with the popular mplab icd 2 system (rj11) or with the new high speed, noise tolerant, low- voltage differential signal (lvds) interconnection (cat5). mplab real ice is field upgradeable through future firmware downloads in mplab ide. in upcoming releases of mplab ide, new devices will be supported, and new features will be added, such as software break- points and assembly code trace. mplab real ice offers significant advantages over competitive emulators including low-cost, full-speed emulation, real-time variable watches, trace analysis, complex breakpoints, a ruggedized probe interface and long (up to three meters) interconnection cables. 18.9 mplab icd 2 in-circuit debugger microchip?s in-circuit debugger, mplab icd 2, is a powerful, low-cost, run-time development tool, connecting to the host pc via an rs-232 or high-speed usb interface. this tool is based on the flash pic mcus and can be used to develop for these and other pic mcus and dspic dscs. the mplab icd 2 utilizes the in-circuit debugging capability built into the flash devices. this feature, along with microchip?s in-circuit serial programming tm (icsp tm ) protocol, offers cost- effective, in-circuit flash debugging from the graphical user interface of the mplab integrated development environment. this enables a designer to develop and debug source code by setting breakpoints, single step- ping and watching variables, and cpu status and peripheral registers. running at full speed enables testing hardware and applications in real time. mplab icd 2 also serves as a development programmer for selected pic devices. 18.10 mplab pm3 device programmer the mplab pm3 device programmer is a universal, ce compliant device programmer with programmable voltage verification at v ddmin and v ddmax for maximum reliability. it features a large lcd display (128 x 64) for menus and error messages and a modu- lar, detachable socket assembly to support various package types. the icsp? cable assembly is included as a standard item. in stand-alone mode, the mplab pm3 device programmer can read, verify and program pic devices without a pc connection. it can also set code protection in this mode. the mplab pm3 connects to the host pc via an rs-232 or usb cable. the mplab pm3 has high-speed communications and optimized algorithms for quick programming of large memory devices and incorporates an sd/mmc card for file storage and secure data applications.
pic16f913/914/916/917/946 ds41250f-page 254 ? 2007 microchip technology inc. 18.11 picstart plus development programmer the picstart plus development programmer is an easy-to-use, low-cost, prototype programmer. it connects to the pc via a com (rs-232) port. mplab integrated development environment software makes using the programmer simple and efficient. the picstart plus development programmer supports most pic devices in dip packages up to 40 pins. larger pin count devices, such as the pic16c92x and pic17c76x, may be supported with an adapter socket. the picstart plus development programmer is ce compliant. 18.12 pickit 2 development programmer the pickit? 2 development programmer is a low-cost programmer and selected flash device debugger with an easy-to-use interface for programming many of microchip?s baseline, mid-range and pic18f families of flash memory microcontrollers. the pickit 2 starter kit includes a prototyping development board, twelve sequential lessons, software and hi-tech?s picc? lite c compiler, and is designed to help get up to speed quickly using pic ? microcontrollers. the kit provides everything needed to program, evaluate and develop applications using microchip?s powerful, mid-range flash memory family of microcontrollers. 18.13 demonstration, development and evaluation boards a wide variety of demonstration, development and evaluation boards for various pic mcus and dspic dscs allows quick application development on fully func- tional systems. most boards include prototyping areas for adding custom circuitry and provide application firmware and source code for examination and modification. the boards support a variety of features, including leds, temperature sensors, switches, speakers, rs-232 interfaces, lcd displays, potentiometers and additional eeprom memory. the demonstration and development boards can be used in teaching environments, for prototyping custom circuits and for learning about various microcontroller applications. in addition to the picdem? and dspicdem? demon- stration/development board series of circuits, microchip has a line of evaluation kits and demonstration software for analog filter design, k ee l oq ? security ics, can, irda ? , powersmart ? battery management, seeval ? evaluation system, sigma-delta adc, flow rate sensing, plus many more. check the microchip web page (www.microchip.com) and the latest ?product selector guide? (ds00148) for the complete list of demonstration, development and evaluation kits.
? 2007 microchip technology inc. ds41250f-page 255 pic16f913/914/916/917/946 19.0 electrical specifications absolute maximum ratings (?) ambient temperature under bias................................................................................................. .........-40 to +125c storage temperature ............................................................................................................ ............ -65c to +150c voltage on v dd with respect to v ss ................................................................................................... -0.3v to +6.5v voltage on mclr with respect to vss ............................................................................................... -0.3v to +1 3.5v voltage on all other pins with respect to v ss ........................................................................... -0.3v to (v dd + 0.3v) total power dissipation (1) ............................................................................................................................... 800 mw maximum current out of v ss pin ....................................................................................................................... 95 m a maximum current into v dd pin .......................................................................................................................... 9 5 ma input clamp current, i ik (v i < 0 or v i > v dd ) ................................................................................................................ 20 ma output clamp current, i ok (vo < 0 or vo >v dd ) .......................................................................................................... 20 ma maximum output current sunk by any i/o pin..................................................................................... ............... 25 ma maximum output current sourced by any i/o pin .................................................................................. ............ 25 ma maximum current sourced by all ports (combined) ................................................................................ ........... 90 ma maximum current sunk by all ports (combined) ................................................................................... ............. 90 ma note 1: power dissipation is calculated as follows: p dis = v dd x {i dd ? i oh } + {(v dd ? v oh ) x i oh } + (v ol x i ol ). 2: portd and porte are not implemented in pic16f913/916 devices. ? notice: stresses above those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure to maximum rating conditions for extended periods may affect device reliability.
pic16f913/914/916/917/946 ds41250f-page 256 ? 2007 microchip technology inc. figure 19-1: pic16f913/914/916/917/946 voltage-frequency graph, -40c t a +125c figure 19-2: hfintosc frequency accuracy over device v dd and temperature 5.5 2.0 3.5 2.5 0 3.0 4.0 4.5 5.0 frequency (mhz) v dd (v) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 820 10 125 25 2.0 0 60 85 v dd (v) 4.0 5.0 4.5 temperature ( c ) 2.5 3.0 3.5 5.5 1% 2% 5%
? 2007 microchip technology inc. ds41250f-page 257 pic16f913/914/916/917/946 19.1 dc characteristics: pic16f913/914/916/917/946-i (industrial) pic16f913/914/916/917/946-e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. sym. characteristic min. typ? max. units conditions d001 d001c d001d v dd supply voltage 2.0 2.0 3.0 4.5 ? ? ? ? 5.5 5.5 5.5 5.5 v v v v f osc < = 8 mhz: hfintosc, ec f osc < = 4 mhz f osc < = 10 mhz f osc < = 20 mhz d002* v dr ram data retention voltage (1) 1.5 ? ? v device in sleep mode d003 v por v dd start voltage to ensure internal power-on reset signal ?v ss ?vsee section 16.2.1 ?power-on reset (por)? for details. d004* s vdd v dd rise rate to ensure internal power-on reset signal 0.05 ? ? v/ms see section 16.2.1 ?power-on reset (por)? for details. * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data.
pic16f913/914/916/917/946 ds41250f-page 258 ? 2007 microchip technology inc. 19.2 dc characteristics: pic16f913/914/916/917/946-i (industrial) pic16f913/914/916/917/946-e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. device characteristics min. typ? max. units conditions v dd note d010 supply current (i dd ) (1, 2) ?13 19 a2.0f osc = 32 khz lp oscillator mode ?22 30 a3.0 ?33 60 a5.0 d011* ? 180 250 a2.0f osc = 1 mhz xt oscillator mode ? 290 400 a3.0 ? 490 650 a5.0 d012 ? 280 380 a2.0f osc = 4 mhz xt oscillator mode ? 480 670 a3.0 ?0.91.4ma5.0 d013* ? 170 295 a2.0f osc = 1 mhz ec oscillator mode ? 280 480 a3.0 ? 470 690 a5.0 d014 ? 290 450 a2.0f osc = 4 mhz ec oscillator mode ? 490 720 a3.0 ?0.851.3 ma 5.0 d015 ? 8 20 a2.0f osc = 31 khz lfintosc mode ?16 40 a3.0 ?31 65 a5.0 d016* ? 416 520 a2.0f osc = 4 mhz hfintosc mode ? 640 840 a3.0 ?1.131.6 ma 5.0 d017 ? 0.65 0.9 ma 2.0 f osc = 8 mhz hfintosc mode ? 1.01 1.3 ma 3.0 ? 1.86 2.3 ma 5.0 d018 ? 340 580 a2.0f osc = 4 mhz extrc mode (3) ? 550 900 a3.0 ?0.921.4 ma 5.0 d019 ? 3.8 4.7 ma 4.5 f osc = 20 mhz hs oscillator mode ?4.04.8ma5.0 * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external square wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and frequency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pattern and temperature, also have an impact on the current consumption. 3: for rc oscillator configurations, current through r ext is not included. the current through the resistor can be extended by the formula i r = v dd /2r ext (ma) with r ext in k .
? 2007 microchip technology inc. ds41250f-page 259 pic16f913/914/916/917/946 19.3 dc characteristics: pic16f913/914/916/917/946-i (industrial) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial param no. device characteristics min. typ? max. units conditions v dd note d020 power-down base current(i pd ) (2) ? 0.05 1.2 a 2.0 wdt, bor, comparators, v ref and t1osc disabled ? 0.15 1.5 a3.0 ? 0.35 1.8 a5.0 ? 150 500 na 3.0 -40c t a +25c d021 ? 1.0 2.2 a 2.0 wdt current (1) ?2.04.0 a3.0 ?3.07.0 a5.0 d022a ? 42 60 a 3.0 bor current (1) ? 85 122 a5.0 d022b ? 22 28 a 2.0 plvd current ?2535 a3.0 ?3345 a5.0 d023 ? 32 45 a 2.0 comparator current (1) , both comparators enabled ?6078 a3.0 ? 120 160 a5.0 d024 ? 30 36 a2.0cv ref current (1) (high range) ?4555 a3.0 ?7595 a5.0 d025* ? 39 47 a2.0cv ref current (1) (low range) ?5972 a3.0 ? 98 124 a5.0 d026 ? 2.0 5.0 a 2.0 t1osc current (1) , 32.768 khz ?2.55.5 a3.0 ?3.07.0 a5.0 d027 ? 0.30 1.6 a 3.0 a/d current (1) , no conversion in progress ? 0.36 1.9 a5.0 * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 2: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in high-impedance state and tied to v dd .
pic16f913/914/916/917/946 ds41250f-page 260 ? 2007 microchip technology inc. 19.4 dc characteristics: pic16f913/914/916/917/946 -e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c for extended param no. device characteristics min. typ? max. units conditions v dd note d020e power-down base current (i pd ) (2) ?0.05 9 a 2.0 wdt, bor, comparators, v ref and t1osc disabled ?0.15 11 a3.0 ?0.35 15 a5.0 d021e ? 1 28 a 2.0 wdt current (1) ?2 30 a3.0 ?3 35 a5.0 d022e ? 42 65 a 3.0 bor current (1) ?85127 a5.0 d022b ? 22 48 a 2.0 plvd current ?25 55 a3.0 ?33 65 a5.0 d023e ? 32 45 a 2.0 comparator current (1) , both comparators enabled ?60 78 a3.0 ?120160 a5.0 d024e ? 30 70 a2.0cv ref current (1) (high range) ?45 90 a3.0 ?75120 a5.0 d025e* ? 39 91 a2.0cv ref current (1) (low range) ?59117 a3.0 ?98156 a5.0 d026e ? 3.5 18 a 2.0 t1osc current (1) , 32.768 khz ?4 21 a3.0 ?5 24 a5.0 d027e ? 0.30 12 a 3.0 a/d current (1) , no conversion in progress ?0.36 16 a5.0 * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 2: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in high-impedance state and tied to v dd .
? 2007 microchip technology inc. ds41250f-page 261 pic16f913/914/916/917/946 19.5 dc characteristics: pic16f913/914/916/917/946-i (industrial) pic16f913/914/916/917/946-e (extended) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. sym. characteristic min. typ? max. units conditions v il input low voltage i/o port: d030 with ttl buffer vss ? 0.8 v 4.5v v dd 5.5v d030a vss ? 0.15 v dd v2.0v v dd 4.5v d031 with schmitt trigger buffer vss ? 0.2 v dd v2.0v v dd 5.5v d032 mclr , osc1 (rc mode) (1) v ss ?0.2 v dd v d033 osc1 (xt mode) v ss ?0.3v d033a osc1 (hs mode) v ss ?0.3 v dd v v ih input high voltage i/o ports: ? d040 with ttl buffer 2.0 ? v dd v4.5v v dd 5.5v d040a 0.25 v dd + 0.8 ? v dd v2.0v v dd 4.5v d041 with schmitt trigger buffer 0.8 v dd ?v dd v2.0v v dd 5.5v d042 mclr 0.8 v dd ?v dd v d043 osc1 (xt mode) 1.6 ? v dd v d043a osc1 (hs mode) 0.7 v dd ?v dd v d043b osc1 (rc mode) 0.9 v dd ?v dd v (note 1) i il input leakage current (2) d060 i/o ports ? 0.1 1 av ss v pin v dd , pin at high-impedance d061 mclr (3) ? 0.1 5 av ss v pin v dd d063 osc1 ? 0.1 5 av ss v pin v dd , xt, hs and lp oscillator configuration d070* i pur portb weak pull-up current 50 250 400 av dd = 5.0v, v pin = v ss v ol output low voltage (5) d080 i/o ports ? ? 0.6 v i ol = 8.5 ma, v dd = 4.5v (ind.) v oh output high voltage (5) d090 i/o ports v dd ? 0.7 ? ? v i oh = -3.0 ma, v dd = 4.5v (ind.) * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise st ated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1 /clkin pin is a schmitt trigger input. it is not recommended to use an external clock in rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 4: see section 13.0 ?data eeprom and flash program memory control? for additional information. 5: including osc2 in clkout mode.
pic16f913/914/916/917/946 ds41250f-page 262 ? 2007 microchip technology inc. capacitive loading specs on output pins d101* cosc2 osc2 pin ? ? 15 pf in xt, hs and lp modes when external clock is used to drive osc1 d101a* c io all i/o pins ? ? 50 pf data eeprom memory d120 e d byte endurance 100k 1m ? e/w -40c t a +85c d120a e d byte endurance 10k 100k ? e/w +85c t a +125c d121 v drw v dd for read/write v min ? 5.5 v using eecon1 to read/write v min = minimum operating voltage d122 t dew erase/write cycle time ? 5 6 ms d123 t retd characteristic retention 40 ? ? year provided no other specifications are violated d124 t ref number of total erase/write cycles before refresh (4) 1m 10m ? e/w -40c t a +85c program flash memory d130 e p cell endurance 10k 100k ? e/w -40c t a +85c d130a e d cell endurance 1k 10k ? e/w +85c t a +125c d131 v pr v dd for read v min ?5.5vv min = minimum operating voltage d132 v pew v dd for erase/write 4.5 ? 5.5 v d133 t pew erase/write cycle time ? ? 3 ms d134 t retd characteristic retention 40 ? ? year provided no other specifications are violated 19.5 dc characteristics: pic16f913/914/916/917/946-i (industrial) pic16f913/914/916/917/946-e (extended) (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. sym. characteristic min. typ? max. units conditions * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise st ated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1 /clkin pin is a schmitt trigger input. it is not recommended to use an external clock in rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 4: see section 13.0 ?data eeprom and flash program memory control? for additional information. 5: including osc2 in clkout mode.
? 2007 microchip technology inc. ds41250f-page 263 pic16f913/914/916/917/946 19.6 thermal considerations standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. symbol characteristic typ. units conditions th01 ja thermal resistance junction to ambient 60.0 c/w 28-pin pdip package 80.0 c/w 28-pin soic package 90.0 c/w 28-pin ssop package 27.5 c/w 28-pin qfn 6x6 mm package 47.2 c/w 40-pin pdip package 46.0 c/w 44-pin tqfp package 24.4 c/w 44-pin qfn 8x8 mm package 77.0 c/w 64-pin tqfp package th02 jc thermal resistance junction to case 31.4 c/w 28-pin pdip package 24.0 c/w 28-pin soic package 24.0 c/w 28-pin ssop package 20.0 c/w 28-pin qfn 6x6 mm package 24.7 c/w 40-pin pdip package 14.5 c/w 44-pin tqfp package 20.0 c/w 44-pin qfn 8x8 mm package 24.4 c/w 64-pin tqfp package th03 t j junction temperature 150 c for derated power calculations th04 pd power dissipation ? w pd = p internal + p i / o th05 p internal internal power dissipation ? w p internal = i dd x v dd (note 1) th06 p i / o i/o power dissipation ? w p i / o = (i ol * v ol ) + (i oh * (v dd - v oh )) th07 p der derated power ? w p der = (t j - t a )/ ja (note 2, 3) note 1: i dd is current to run the chip alone without driving any load on the output pins. 2: t a = ambient temperature. 3: maximum allowable power dissipation is the lower value of either the absolute maximum total power dissipation or derated power (p der ).
pic16f913/914/916/917/946 ds41250f-page 264 ? 2007 microchip technology inc. 19.7 timing parameter symbology the timing parameter symbols have been created with one of the following formats: figure 19-3: load conditions 1. tpps2pps 2. tpps t f frequency t time lowercase letters (pp) and their meanings: pp cc ccp1 osc osc1 ck clkout rd rd cs cs rw rd or wr di sdi sc sck do sdo ss ss dt data in t0 t0cki io i/o port t1 t1cki mc mclr wr wr uppercase letters and their meanings: s ffall pperiod hhigh rrise i invalid (high-impedance) v valid l low z high-impedance v ss c l legend: c l = 50 pf for all pins 15 pf for osc2 output load condition pin
? 2007 microchip technology inc. ds41250f-page 265 pic16f913/914/916/917/946 19.8 ac characteristics: pic16f913/914/916/917/946 (industrial, extended) figure 19-4: clock timing table 19-1: clock oscillator timing requirements standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions os01 f osc external clkin frequency (1) dc ? 37 khz lp oscillator mode dc ? 4 mhz xt oscillator mode dc ? 20 mhz hs oscillator mode dc ? 20 mhz ec oscillator mode oscillator frequency (1) ? 32.768 ? khz lp oscillator mode 0.1 ? 4 mhz xt oscillator mode 1 ? 20 mhz hs oscillator mode dc ? 4 mhz rc oscillator mode os02 t osc external clkin period (1) 27 ? ? s lp oscillator mode 250 ? ns xt oscillator mode 50 ? ns hs oscillator mode 50 ? ns ec oscillator mode oscillator period (1) ?30.5 ? s lp oscillator mode 250 ? 10,000 ns xt oscillator mode 50 ? 1,000 ns hs oscillator mode 250 ? ? ns rc oscillator mode os03 t cy instruction cycle time (1) 200 t cy dc ns t cy = 4/f osc os04* tosh, tos l external clkin high, external clkin low 2?? s lp oscillator 100 ? ? ns xt oscillator 20 ? ? ns hs oscillator os05* tosr, tos f external clkin rise, external clkin fall 0? ns lp oscillator 0? ns xt oscillator 0? ns hs oscillator * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstable oscillator operation and/or higher than expected current consumption. all devices are tested to operate at ?min? values with an external clock applied to osc1 pin. when an external clock input is used, the ?max? cycle time limit is ?dc? (no clock) for all devices. osc1/clkin osc2/clkout q4 q1 q2 q3 q4 q1 os02 os03 os04 os04 osc2/clkout (lp, xt, hs modes) (clkout mode)
pic16f913/914/916/917/946 ds41250f-page 266 ? 2007 microchip technology inc. table 19-2: oscillator parameters standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic freq. tolerance min. typ? max. units conditions os06 t warm internal oscillator switch when running (3) ???2t osc slowest clock os07 t sc fail-safe sample clock period (1) ? ?21?mslfintosc/64 os08 hf osc internal calibrated hfintosc frequency (2) 1% 7.92 8.0 8.08 mhz v dd = 3.5v, 25c 2% 7.84 8.0 8.16 mhz 2.5v v dd 5.5v, 0c t a +85c 5% 7.60 8.0 8.40 mhz 2.0v v dd 5.5v, -40c t a +85c (ind.), -40c t a +125c (ext.) os09* lf osc internal uncalibrated lfintosc frequency ? 153145khz os10* t iosc st hfintosc oscillator wake-up from sleep start-up time ? 5.5 12 24 sv dd = 2.0v, -40c to +85c ?3.5714 sv dd = 3.0v, -40c to +85c ?3611 sv dd = 5.0v, -40c to +85c * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstable oscillator operation and/or higher than expected current consumption. all devices are tested to operate at ?min? values with an external clock applied to the osc1 pin. when an external clock input is used, the ?max? cycle time limit is ?dc? (no clock) for all devices. 2: to ensure these oscillator frequency tolerances, v dd and v ss must be capacitively decoupled as close to the device as possible. 0.1 f and 0.01 f values in parallel are recommended. 3: by design.
? 2007 microchip technology inc. ds41250f-page 267 pic16f913/914/916/917/946 figure 19-5: clkout and i/o timing f osc clkout i/o pin (input) i/o pin (output) q4 q1 q2 q3 os11 os19 os13 os15 os18, os19 os20 os21 os17 os16 os14 os12 os18 old value new value write fetch read execute cycle table 19-3: clkout and i/o timing parameters standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. symbol characteristic min. typ? max. units conditions os11 t os h2 ck lf osc to clkout (1) ? ? 70 ns v dd = 5.0v os12 t os h2 ck hf osc to clkout (1) ? ? 72 ns v dd = 5.0v os13 t ck l2 io vclkout to port out valid (1) ? ? 20 ns os14 t io v2 ck h port input valid before clkout (1) t osc + 200 ns ? ? ns os15* t os h2 io vf osc (q1 cycle) to port out valid ? 50 70 ns v dd = 5.0v os16 t os h2 io if osc (q2 cycle) to port input invalid (i/o in hold time) 50 ? ? ns v dd = 5.0v os17 t io v2 os h port input valid to f osc (q2 cycle) (i/o in setup time) 20 ? ? ns os18 t io r port output rise time (2) ? ? 15 40 72 32 ns v dd = 2.0v v dd = 5.0v os19 t io f port output fall time (2) ? ? 28 15 55 30 ns v dd = 2.0v v dd = 5.0v os20* t inp int pin input high or low time 25 ? ? ns os21* t rap porta interrupt-on-change new input level time t cy ??ns * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. note 1: measurements are taken in rc mode where clkout output is 4 x t osc . 2: includes osc2 in clkout mode.
pic16f913/914/916/917/946 ds41250f-page 268 ? 2007 microchip technology inc. figure 19-6: reset, watchdog timer, oscillator start-up timer and power-up timer timing figure 19-7: brown-out rese t timing and characteristics v dd mclr internal por pwrt time-out osc start-up time internal reset (1) watchdog timer 33 32 30 31 34 i/o pins 34 note 1: asserted low. reset (1) v bor v dd (device in brown-out reset) (device not in brown-out reset) 33* 37 bor reset v bor + v hyst (if pwrte = 1 ) bor reset (if pwrte = 0 )
? 2007 microchip technology inc. ds41250f-page 269 pic16f913/914/916/917/946 table 19-4: reset, watchdog timer, oscill ator start-up timer, power-up timer and brown-out reset parameters standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. symbol characteristic min. typ? max. units conditions 30 t mc lmclr pulse width (low) 2 5 ? ? ? ? s s v dd = 5v, -40c to +85c v dd = 5v 31 t wdt watchdog timer time-out period (no prescaler) 10 10 16 16 29 31 ms ms v dd = 5v, -40c to +85c v dd = 5v 32 t ost oscillation start-up timer period (1, 2) ? 1024 ? t osc (note 3) 33* t pwrt power-up timer period 40 65 140 ms 34* t ioz i/o high-impedance from mclr low or watchdog timer reset ??2.0 s 35 v bor brown-out reset voltage 2.0 2.0 ? ? 2.2 2.25 v v -40c to +85c, (note 4) -40c to +125c, (note 4) 36* v hyst brown-out reset hysteresis ? 50 ? mv 37* t bor brown-out reset minimum detection period 100 ? ? sv dd v bor * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstable oscillator oper- ation and/or higher than expected current consumption. all devices are tested to operate at ?min? values with an external clock applied to the osc1 pin. when an external clock input is used, the ?max? cycle time limit is ?dc? (no clock) for all devices. 2: by design. 3: period of the slower clock. 4: to ensure these voltage tolerances, v dd and v ss must be capacitively decoupled as close to the device as possible. 0.1 f and 0.01 f values in parallel are recommended.
pic16f913/914/916/917/946 ds41250f-page 270 ? 2007 microchip technology inc. figure 19-8: timer0 and time r1 external clock timings table 19-5: timer0 and timer1 external clock requirements standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. symbol characteristic min. typ? max. units conditions 40* t t 0h t0cki high pulse width no prescaler 0.5 t cy + 20 ? ? ns with prescaler 10 ? ? ns 41* t t 0l t0cki low pulse width no prescaler 0.5 t cy + 20 ? ? ns with prescaler 10 ? ? ns 42* t t 0p t0cki period greater of: 20 or t cy + 40 n ? ? ns n = prescale value (2, 4, ..., 256) 45* t t 1h t1cki high time synchronous, no prescaler 0.5 t cy + 20 ? ? ns synchronous, with prescaler 15 ? ? ns asynchronous 30 ? ? ns 46* t t 1l t1cki low time synchronous, no prescaler 0.5 t cy + 20 ? ? ns synchronous, with prescaler 15 ? ? ns asynchronous 30 ? ? ns 47* t t 1p t1cki input period synchronous greater of: 30 or t cy + 40 n ? ? ns n = prescale value (1, 2, 4, 8) asynchronous 60 ? ? ns 48 f t 1 timer1 oscillator input frequency range (oscillator enabled by setting bit t1oscen) ? 32.768 ? khz 49* tckez tmr 1 delay from external clock edge to timer increment 2 t osc ?7 t osc ? timers in sync mode * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. t0cki t1cki 40 41 42 45 46 47 49 tmr0 or tmr1
? 2007 microchip technology inc. ds41250f-page 271 pic16f913/914/916/917/946 table 19-6: comparator specifications table 19-7: comparator voltage reference (cv ref ) specifications standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. symbol characteristics min. typ? max. units comments cm01 v os input offset voltage ? 5.0 10 mv (v dd - 1.5)/2 cm02 v cm input common mode voltage 0 ? v dd ? 1.5 v cm03* c mrr common mode rejection ratio +55 ? ? db cm04* t rt response time falling ? 150 600 ns (note 1) rising ? 200 1000 ns cm05* t mc 2 co v comparator mode change to output valid ?? 10 s * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: response time is measured with one comparator input at (v dd - 1.5)/2 - 100 mv to (v dd -1.5)/2+20mv. standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. symbol characteristics min. typ? max. units comments cv01* c lsb step size (2) ? ? v dd /24 v dd /32 ? ? v v low range (vrr = 1 ) high range (vrr = 0 ) cv02* c acc absolute accuracy ? ? ? ? 1/2 1/2 lsb lsb low range (vrr = 1 ) high range (vrr = 0 ) cv03* c r unit resistor value (r) ? 2k ? cv04* c st settling time (1) ??10 s * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: settling time measured while vrr = 1 and vr<3:0> transitions from ? 0000 ? to ? 1111 ?. 2: see section 8.10 ?comparator voltage reference? for more information.
pic16f913/914/916/917/946 ds41250f-page 272 ? 2007 microchip technology inc. table 19-8: pic16f913/914/916/917/9 46 a/d converter (adc) characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions ad01 n r resolution ? ? 10 bits bit ad02 e il integral error ? ? 1lsbv ref = 5.12v ad03 e dl differential error ? ? 1 lsb no missing codes to 10 bits v ref = 5.12v ad04 e off offset error ? ? 1lsbv ref = 5.12v ad07 e gn gain error ? ? 1lsbv ref = 5.12v ad06 ad06a v ref reference voltage (1) 2.2 2.7 ?v dd v dd v absolute minimum to ensure 1 lsb accuracy ad07 v ain full-scale range v ss ?v ref v ad08 z ain recommended impedance of analog voltage source ?? 10k ad09* i ref v ref input current (1) 10 ? 1000 aduring v ain acquisition. based on differential of v hold to v ain . ?? 50 a during a/d conversion cycle. * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: adc v ref is from external v ref or v dd pin, whichever is selected as reference input.
? 2007 microchip technology inc. ds41250f-page 273 pic16f913/914/916/917/946 table 19-9: pic16f913/914/916/917/946 a/d conversion requirements standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions ad130* t ad a/d clock period 1.6 ? 9.0 st osc -based, v ref 3.0v 3.0 ? 9.0 st osc -based, v ref full range a/d internal rc oscillator period 3.0 6.0 9.0 s adcs<1:0> = 11 (adrc mode) at v dd = 2.5v 1.6 4.0 6.0 sat v dd = 5.0v ad131 t cnv conversion time (not including acquisition time) (1) ?11?t ad set go/done bit to new data in a/d result register ad132* t acq acquisition time 11.5 ? s ad133* t amp amplifier settling time ? ? 5 s ad134 t go q4 to a/d clock start ? ? t osc /2 t osc /2 + t cy ? ? ? ? if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: adresh and adresl registers may be read on the following t cy cycle. 2: see section 12.3 ?a/d acquisition requirements? for minimum conditions.
pic16f913/914/916/917/946 ds41250f-page 274 ? 2007 microchip technology inc. figure 19-9: pic16f913/914/916/917/946 a/d conversion timing (normal mode) figure 19-10: pic16f913/914/916/917/946 a/d conversion timing (sleep mode) ad131 ad130 bsf adcon0, go q4 a/d clk a/d data adres adif go sample old_data sampling stopped done new_data 987 3210 note 1: if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. 1 t cy 6 ad134 (t osc /2 (1) ) 1 t cy ad132 ad132 ad131 ad130 bsf adcon0, go q4 a/d clk a/d data adres adif go sample old_data sampling stopped done new_data 9 7 3210 note 1: if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. ad134 6 8 1 t cy (t osc /2 + t cy (1) ) 1 t cy
? 2007 microchip technology inc. ds41250f-page 275 pic16f913/914/916/917/946 figure 19-11: usart synchronous transmission (master/slave) timing table 19-10: usart synchronous tran smission requirements figure 19-12: usart synchrono us receive (master/slave) timing table 19-11: usart synchronous receive requirements standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param. no. symbol characteristic min. max. units conditions 120 t ck h2 dt v sync xmit (m aster and s lave ) clock high to data-out valid 3.0-5.5v ? 80 ns 2.0-5.5v ? 100 ns 121 t ckrf clock out rise time and fall time (master mode) 3.0-5.5v ? 45 ns 2.0-5.5v ? 50 ns 122 t dtrf data-out rise time and fall time 3.0-5.5v ? 45 ns 2.0-5.5v ? 50 ns standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param. no. symbol characteristic min. max. units conditions 125 t dt v2 ckl sync rcv (m aster and s lave ) data-hold before ck (dt hold time) 10 ? ns 126 t ck l2 dtl data-hold after ck (dt hold time) 15 ? ns note: refer to figure 19-3 for load conditions. 121 121 120 122 rc6/tx/ck rc7/rx/dt/ sck/scl/seg9 sdi/sda/seg8 note: refer to figure 19-3 for load conditions. 125 126 rc6/tx/ck sck/scl/seg9 rc7/rx/dt/ sdi/sda/seg8
pic16f913/914/916/917/946 ds41250f-page 276 ? 2007 microchip technology inc. figure 19-13: capture/compare/pwm timings table 19-12: capture/compare/pwm (ccp) requirements param. no. sym. characteristic min. typ? max. units conditions 50* t cc lccpx input low time no prescaler 0.5t cy + 5 ? ? ns with prescaler 3.0-5.5v 10 ? ? ns 2.0-5.5v 20 ? ? ns 51* t cc h ccpx input high time no prescaler 0.5t cy + 5 ? ? ns with prescaler 3.0-5.5v 10 ? ? ns 2.0-5.5v 20 ? ? ns 52* t cc p ccpx input period 3t cy + 40 n ? ? ns n = prescale value (1,4 or 16) 53* t cc r ccpx output fall time 3.0-5.5v ? 10 25 ns 2.0-5.5v ? 25 50 ns 54* t cc f ccpx output fall time 3.0-5.5v ? 10 25 ns 2.0-5.5v ? 25 45 ns * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. note: refer to figure 19-3 for load conditions. (capture mode) 50 51 52 53 54 ccp1/ccp2 (compare mode) ccp1/ccp2
? 2007 microchip technology inc. ds41250f-page 277 pic16f913/914/916/917/946 table 19-13: pic16f913/914/9 16/917/946 plvd characteristics : dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c operating voltage v dd range 2.0v-5.5v sym. characteristic min. typ? max. (85c) max. (125c) units conditions v plvd plvd voltage lvdl<2:0> = 001 1.900 2.0 2.100 2.125 v lvdl<2:0> = 010 2.000 2.1 2.200 2.225 v lvdl<2:0> = 011 2.100 2.2 2.300 2.325 v lvdl<2:0> = 100 2.200 2.3 2.400 2.425 v lvdl<2:0> = 101 3.825 4.0 4.175 4.200 v lvdl<2:0> = 110 4.025 4.2 4.375 4.400 v lvdl<2:0> = 111 4.425 4.5 4.675 4.700 v *t plvds plvd settling time ? 50 25 ?? sv dd = 5.0v v dd = 3.0v * these parameters are characterized but not tested ? data in ?typ? column is at 5.0v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested.
pic16f913/914/916/917/946 ds41250f-page 278 ? 2007 microchip technology inc. figure 19-14: spi master mode timing (cke = 0 , smp = 0 ) figure 19-15: spi master mode timing (cke = 1 , smp = 1 ) ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi 70 71 72 73 74 75, 76 78 79 80 79 78 msb lsb bit 6 - - - - - -1 msb in lsb in bit 6 - - - -1 note: refer to figure 19-3 for load conditions. ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi 81 71 72 74 75, 76 78 80 msb 79 73 msb in bit 6 - - - - - -1 lsb in bit 6 - - - -1 lsb note: refer to figure 19-3 for load conditions.
? 2007 microchip technology inc. ds41250f-page 279 pic16f913/914/916/917/946 figure 19-16: spi slav e mode timing (cke = 0 ) figure 19-17: spi slav e mode timing (cke = 1 ) ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi 70 71 72 73 74 75, 76 77 78 79 80 79 78 msb lsb bit 6 - - - - - -1 msb in bit 6 - - - -1 lsb in 83 note: refer to figure 19-3 for load conditions. ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi 70 71 72 82 74 75, 76 msb bit 6 - - - - - -1 lsb 77 msb in bit 6 - - - -1 lsb in 80 83 note: refer to figure 19-3 for load conditions.
pic16f913/914/916/917/946 ds41250f-page 280 ? 2007 microchip technology inc. table 19-14: spi mode requirements figure 19-18: i 2 c? bus start/stop bits timing param no. symbol characteristic min. typ? max. units conditions 70* t ss l2 sc h, t ss l2 sc l ss to sck or sck input t cy ??ns 71* t sc h sck input high time (slave mode) t cy + 20 ? ? ns 72* t sc l sck input low time (slave mode) t cy + 20 ? ? ns 73* t di v2 sc h, t di v2 sc l setup time of sdi data input to sck edge 100 ? ? ns 74* t sc h2 di l, t sc l2 di l hold time of sdi data input to sck edge 100 ? ? ns 75* t do r sdo data output rise time 3.0-5.5v ? 10 25 ns 2.0-5.5v ? 25 50 ns 76* t do f sdo data output fall time ? 10 25 ns 77* t ss h2 do zss to sdo output high-impedance 10 ? 50 ns 78* t sc r sck output rise time (master mode) 3.0-5.5v ? 10 25 ns 2.0-5.5v ? 25 50 ns 79* t sc f sck output fall time (master mode) ? 10 25 ns 80* t sc h2 do v, t sc l2 do v sdo data output valid after sck edge 3.0-5.5v ? ? 50 ns 2.0-5.5v ? ? 145 ns 81* t do v2 sc h, t do v2 sc l sdo data output setup to sck edge tcy ? ? ns 82* t ss l2 do v sdo data output valid after ss edge ? ? 50 ns 83* t sc h2 ss h, t sc l2 ss h ss after sck edge 1.5t cy + 40 ? ? ns * these parameters are characterized but not tested. ? data in ?typ? column is at 5.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note : refer to figure 19-3 for load conditions. 91 92 93 scl sda start condition stop condition 90
? 2007 microchip technology inc. ds41250f-page 281 pic16f913/914/916/917/946 table 19-15: i 2 c? bus start/stop bits requirements figure 19-19: i 2 c? bus data timing param no. symbol characteristic min. typ. max. units conditions 90* t su : sta start condition setup time 400 khz mode 600 ? ? ns only relevant for repeated start condition 91* t hd : sta start condition hold time 400 khz mode 600 ? ? ns after this period, the first clock pulse is generated 92* t su : sto stop condition setup time 400 khz mode 600 ? ? ns 93 t hd : sto stop condition hold time 400 khz mode 600 ? ? ns * these parameters are characterized but not tested. note: refer to figure 19-3 for load conditions. 90 91 92 100 101 103 106 107 109 109 110 102 scl sda in sda out
pic16f913/914/916/917/946 ds41250f-page 282 ? 2007 microchip technology inc. table 19-16: i 2 c? bus data requirements param. no. symbol characteristic min. max. units conditions 100* t high clock high time 400 khz mode 0.6 ? s device must operate at a minimum of 10 mhz ssp module 1.5t cy ? 101* t low clock low time 400 khz mode 1.3 ? s device must operate at a minimum of 10 mhz ssp module 1.5t cy ? 102* t r sda and scl rise time 400 khz mode 20 + 0.1c b 250 ns c b is specified to be from 10-400 pf 103* t f sda and scl fall time 400 khz mode 20 + 0.1c b 250 ns c b is specified to be from 10-400 pf 90* t su : sta start condition setup time 400 khz mode 1.3 ? s only relevant for repeated start condition 91* t hd : sta start condition hold time 400 khz mode 0.6 ? s after this period the first clock pulse is generated 106* t hd : dat data input hold time 400 khz mode 0 0.9 s 107* t su : dat data input setup time 400 khz mode 100 ? ns (note 2) 92* t su : sto stop condition setup time 400 khz mode 0.6 ? s 109* t aa output valid from clock 400 khz mode ? ? ns (note 1) 110* t buf bus free time 400 khz mode 1.3 ? s time the bus must be free before a new transmission can start c b bus capacitive loading ? 400 pf * these parameters are characterized but not tested. note 1: as a transmitter, the device must provide this internal mi nimum delay time to bridge the undefined region (min. 300 ns) of the falling edge of scl to avoid unintended generation of start or stop conditions. 2: a fast mode (400 khz) i 2 c bus device can be used in a standard mode (100 khz) i 2 c bus system, but the requirement t su : dat 250 ns must then be met. this will automatically be the case if the device does not stretch the low period of the scl signal. if such a device does stretch the low period of the scl signal, it must output the next data bit to the sda line t r max. + t su : dat = 1000 + 250 = 1250 ns (according to the standard mode i 2 c bus specification), before the scl line is released.
? 2007 microchip technology inc. ds41250f-page 283 pic16f913/914/916/917/946 20.0 dc and ac characteristics graphs and tables the graphs and tables provided in this section are for design guidance and are not tested . in some graphs or tables, the data presented are outside specified operating range (i.e., outside specified v dd range). this is for information only and devices are ensured to operate properly only within the specified range. ?typical? represents the mean of the distribution at 25 c. ?maximum? or ?minimum? represents (mean + 3 ) or (mean - 3 ) respectively, where is a standard deviation, over each temperature range. figure 20-1: typical i dd vs. f osc over v dd (ec mode) note: the graphs and tables provided following this note are a statistical summary based on a limited number of samples and are provided for informational purposes only. the performance characteristics listed herein are not tested or guaranteed. in some graphs or tables, the data presented may be outside the specified operating range (e.g., outside specified power supply range) and therefore, outside the warranted range. typical 2v 3v 4v 5v 5.5v 1mhz 0.086 0.153 0.220 0.277 0.310 2mhz 0.150 0.2596 0.3718 0.4681 0.5236 4mhz 0.279 0.472 0.675 0.850 0.951 6mhz 0.382 0.635 0.903 1.135 1.269 8mhz 0.486 0.798 1.132 1.420 1.587 10mhz 0.589 0.961 1.360 1.706 1.905 12mhz 0.696 1.126 1.596 2.005 2.241 14mhz 0.802 1.291 1.832 2.304 2.577 16mhz 0.908 1.457 2.068 2.603 2.913 18mhz 1.017 1.602 2.268 2.848 3.185 20mhz 1.126 1.748 2.469 3.093 3.458 m ax 2v 3v 4v 5v 5.5v 1mhz 0.168 0.236 0.315 0.412 0.452 2mhz 0.261 0.394 0.537 0.704 0.780 4mhz 0.449 0.710 0.981 1.287 1.435 6mhz 0.577 0.972 1.331 1.739 1.950 8mhz 0.705 1.233 1.682 2.191 2.465 10mhz 0.833 1.495 2.032 2.642 2.979 12mhz 0.956 1.711 2.372 3.101 3.506 14mhz 1.078 1.926 2.713 3.560 4.032 16mhz 1.201 2.142 3.054 4.018 4.558 18mhz 1.305 2.326 3.295 4.324 4.887 20mhz 1.409 2.510 3.536 4.630 ec mode 3v 4v 5v 5.5v 2v 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 1 mhz 2 mhz 4 mhz 6 mhz 8 mhz 10 mhz 12 mhz 14 mhz 16 mhz 18 mhz 20 mhz v dd (v) i dd (ma) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c)
pic16f913/914/916/917/946 ds41250f-page 284 ? 2007 microchip technology inc. figure 20-2: maximum i dd vs. f osc over v dd (ec mode) figure 20-3: typical i dd vs. f osc over v dd (hs mode) 3v 4v 5v 5.5v 2v 0.0 1.0 2.0 3.0 4.0 5.0 6.0 1 mhz 2 mhz 4 mhz 6 mhz 8 mhz 10 mhz 12 mhz 14 mhz 16 mhz 18 mhz 20 mhz v dd (v) i dd (ma) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) 3v 3.5v 4v 4.5v 5v 5.5v 0.567660978 0.6909750.8211857610.9883470541.0462473761.119615457 1.1610564131.4069334781.6664380432.0030751092.1193190652.268818804 2.883088587 3.03554863 3.23775 3.74139 3.967407543 hs mode 3v 3.5v 4v 4.5v 5v 5.5v 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 4 mhz 10 mhz 16 mhz 20 mhz f osc i dd (ma) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c)
? 2007 microchip technology inc. ds41250f-page 285 pic16f913/914/916/917/946 figure 20-4: maximum i dd vs. f osc over v dd (hs mode) figure 20-5: typical i dd vs. v dd over f osc (xt mode) 3v 3.5v 4v 4.5v 5v 5.5v 0.8868608641.0693043161.2645617521.4868166111.5076394231.520959608 1.6176371031.9623642592.3355493582.7630868222.8139211682.849632041 3.8375797553.9157601913.967889512 4.685048474 4.78069621 hs mode 3v 3.5v 4v 4.5v 5v 5.5v 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 4 mhz 10 mhz 16 mhz 20 mhz f osc i dd (ma) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) 2 2.5 3 3.5 4 4.5 5 5.5 180.1774 235.0683 289.9592 337.753 385.547 436.866 488.184 554.8964 283.7333 382.484 481.2347 577.923 674.6106 783.831 893.052 1033.15 vdd 2 2.5 3 3.5 4 4.5 5 5.5 244.8837 320.7132 396.5426 461.707 526.8719 587.642 648.412 724.0755 375.529 522.3721 669.2152 822.619 976.0232 1163.67 1351.32 xt mode 1 mhz 4 mhz 0 200 400 600 800 1,000 1,200 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i dd (ua) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c)
pic16f913/914/916/917/946 ds41250f-page 286 ? 2007 microchip technology inc. figure 20-6: maximum i dd vs. v dd over f osc (xt mode) figure 20-7: typical i dd vs. v dd over f osc (extrc mode) xt mode 4 mhz 1 mhz 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i dd (ua) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) (extrc mode) 1 mhz 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i dd (ua) 4 mhz typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c)
? 2007 microchip technology inc. ds41250f-page 287 pic16f913/914/916/917/946 figure 20-8: maximum i dd vs. v dd (extrc mode) figure 20-9: i dd vs. v dd over f osc (lfintosc mode, 31 khz) 1 mhz 4 mhz 0 200 400 600 800 1,000 1,200 1,400 1,600 1,800 2,000 2 .0 2.5 3 .0 3.5 4 .0 4.5 5 .0 5.5 v dd (v) i dd (ua) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) lfintosc m o d e, 31khz typical maximum 0 10 20 30 40 50 60 70 80 v dd (v) i dd ( a) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
pic16f913/914/916/917/946 ds41250f-page 288 ? 2007 microchip technology inc. figure 20-10: i dd vs. v dd (lp mode) figure 20-11: typical i dd vs. f osc over v dd (hfintosc mode) 0 10 20 30 40 50 60 70 80 2 .0 2.5 3 .0 3.5 4 .0 4.5 5 .0 5.5 v dd (v) i dd (ua) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) 32 khz maximum 32 khz typical 4v 5v 5.5v 197.9192604299.82617395.019 496.999 574.901 210.9124688 324.4079 431.721 544.182 620.66 239.9707708369.77809491.538 623.314 717.723 298.6634479460.30461619.714 793.635 901.409 414.3997292639.99889 878.13 1127.53 1275.6 649.86985881014.40021421.21 1858.97 2097.71 2v 3v 4v 5v 5.5v hfintosc 2v 3v 4v 5v 5.5v 0 500 1,000 1,500 2,000 2,500 125 khz 25 khz 500 khz 1 mhz 2 mhz 4 mhz 8 mhz v dd (v) i dd (ua) typical: statistical mean @25c maximum: mean (worst case temp) + 3 (-40c to 125c) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c)
? 2007 microchip technology inc. ds41250f-page 289 pic16f913/914/916/917/946 figure 20-12: maximum i dd vs. f osc over v dd (hfintosc mode) figure 20-13: typical i pd vs. v dd (sleep mode, all peripherals disabled) hfintosc 2v 3v 4v 5v 5.5v 0 500 1,000 1,500 2,000 2,500 3,000 125 khz 250 khz 500 khz 1 mhz 2 mhz 4 mhz 8 mhz v dd (v) i dd (ua) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) typical (sleep mode all peripherals disabled) 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd (ua) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) 0.00
pic16f913/914/916/917/946 ds41250f-page 290 ? 2007 microchip technology inc. figure 20-14: maximum i pd vs. v dd (sleep mode, all peripherals disabled) figure 20-15: comparator i pd vs. v dd (both comparators enabled) maximum (sleep mode all peripherals disabled) max. 125c max. 85c 0 2 4 6 8 10 12 14 16 18 2.02.5 3.03.5 4.04.5 5.05.5 v dd (v) i pd ( a) maximum: mean + 3 typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) typical max 31.9 43.9 45.6 60.8 59.3 77.7 73.0 95.8 86.7 113.8 100.4 131.8 114.1 149.9 127.7 typical maximum 0 20 40 60 80 100 120 140 160 180 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd (ua) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c)
? 2007 microchip technology inc. ds41250f-page 291 pic16f913/914/916/917/946 figure 20-16: bor i pd vs. v dd over temperature figure 20-17: typical wdt i pd vs. v dd (25 c) typical max 2.5 35.0 51.1 3 44.4 65.0 3.5 56.2 82.5 4 68.1 100.0 4.5 79.9 117.5 5 91.7 135.1 5.5 104.1 0 20 40 60 80 100 120 140 160 180 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd (ua) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) maximum typical typical max 85c max 125c 2 1.007 2.140 27.702 2.5 1.146 2.711 29.079 3 1.285 3.282 30.08 3.5 1.449 3.899 31.347 4 1.612 4.515 32.238 4.5 1.924 5.401 33.129 5 2.237 6.288 34.02 5.5 2.764 7.776 0.0 0.5 1.0 1.5 2.0 2.5 3.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd (ua) typical: statistical mean @25c
pic16f913/914/916/917/946 ds41250f-page 292 ? 2007 microchip technology inc. figure 20-18: maximum wdt i pd vs. v dd over temperature figure 20-19: wdt period vs. v dd over temperature max. 125c max. 85c 0.0 5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd (ua) maximum: mean + 3 maximum: mean + 3 wdt time - out period typical 10 12 14 16 18 20 22 24 26 28 30 32 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) time (ms) maximum: mean + 3 (-40c to 125c) max. (125c) max. (85c) minimum
? 2007 microchip technology inc. ds41250f-page 293 pic16f913/914/916/917/946 figure 20-20: wdt period vs. temperature (v dd = 5.0v) figure 20-21: cv ref i pd vs. v dd over temperature (high range) vdd = 5v maximum typical minimum 10 12 14 16 18 20 22 24 26 28 30 -40c 25c 85c 125c temperature ( c) time (ms) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 max 85c max 125c 35.8 68.0 44.8 77.3 53.8 86.5 62.8 94.3 71.8 102.1 81.0 109.8 90.1 117.6 99.2 125.1 max 85c max 125c 46.5 86.4 58.3 98.1 70.0 109.9 high range typical max. 85c 0 20 40 60 80 100 120 140 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd (ua) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) max. 125c
pic16f913/914/916/917/946 ds41250f-page 294 ? 2007 microchip technology inc. figure 20-22: cv ref i pd vs. v dd over temperature (low range) figure 20-23: lvd i pd vs. v dd over temperature low range typical max. 85c max. 125c 0 20 40 60 80 100 120 140 160 180 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd (ua) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) typical max. 85c max. 125c 0 10 20 30 40 50 60 70 80 2.0v 2.5v 3.0v 3.5v 4.0v 4.5v 5v 5.5v v dd (v) i pd (ua) typical: statistical mean @25c maximum: mean + 3
? 2007 microchip technology inc. ds41250f-page 295 pic16f913/914/916/917/946 figure 20-24: t1osc i pd vs. v dd over temperature (32 khz) figure 20-25: v ol vs. i ol over temperature (v dd = 3.0v) typ 25c max 85c max 125c 2 2.022 4.98 17.54 2.5 2.247 5.23 19.02 3 2.472 5.49 20.29 3.5 2.453 5.79 21.50 4 2.433 6.08 22.45 4.5 2.711 6.54 23.30 5 2.989 7.00 24.00 5.5 3.112 7.34 typ. 25c max. 85c max. 125c 0 5 10 15 20 25 30 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) i pd (ua) typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) (vdd = 3v , - 40 c to 125 c) 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 i ol (ma) v ol (v) max. 85c max. 125c typical 25c min. -40c typical: statistical mean @25c maximum: mean + 3
pic16f913/914/916/917/946 ds41250f-page 296 ? 2007 microchip technology inc. figure 20-26: v ol vs. i ol over temperature (v dd = 5.0v) figure 20-27: v oh vs. i oh over temperature (v dd = 3.0v) 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 i ol (ma) v ol (v) typical: statistical mean maximum: means + 3 typical: statistical mean @25c maximum: mean + 3 max. 85c typ. 25c min. -40c max. 125c 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 i oh (ma) v oh (v) typ. 25c max. -40c min. 125c typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c)
? 2007 microchip technology inc. ds41250f-page 297 pic16f913/914/916/917/946 figure 20-28: v oh vs. i oh over temperature (v dd = 5.0v) figure 20-29: ttl input threshold v in vs. v dd over temperature (, ) 3.0 3.5 4.0 4.5 5.0 5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 i oh (ma) v oh (v) max. -40c typ. 25c min. 125c typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) (ttl input, -40c to 125c) 0.5 0.7 0.9 1.1 1.3 1.5 1.7 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) v in (v) typ. 25c max. -40c min. 125c typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c)
pic16f913/914/916/917/946 ds41250f-page 298 ? 2007 microchip technology inc. figure 20-30: schmitt trigger input threshold v in vs. v dd over temperature figure 20-31: comparator response time (rising edge) (st i npu t , - 40 c to 125 c) 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) v in (v) v ih max. 125c v ih min. -40c v il min. 125c v il max. -40c typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) v- input = transition from v cm + 100 m v to v cm - 20 m v v+ input = v cm 4 200 278 639 846 5.5 140 202 531 0 100 200 300 400 500 600 700 800 900 1,000 2.0 2.5 4.0 5.5 v dd (volts) response time (ns) max. (85c) typ. (25c) min. (-40c) max. (125c) note: v- input = transition from v cm + 100 m v to v cm - 20 m v v+ input = v cm v cm = v dd - 1.5v)/2
? 2007 microchip technology inc. ds41250f-page 299 pic16f913/914/916/917/946 figure 20-32: comparator respo nse time (falling edge) figure 20-33: lfintosc frequency vs. v dd over temperature (31 khz) vdd - 40 c25 c85 c 125 c 2 279 327 547 557 2.5 226 267 425 440 4 172 204 304 319 5.5 119 142 182 0 100 200 300 400 500 600 2.0 2.5 4.0 5.5 v dd (volts) response time (ns) max. (85c) typ. (25c) min. (-40c) note: v- input = transition from v cm - 100 m v to v cm + 20 m v v+ input = v cm v cm = v dd - 1.5v)/2 max. (125c) lfintosc 31khz 0 5,000 10,000 15,000 20,000 25,000 30,000 35,000 40,000 45,000 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) frequency (hz) max. -40c typ. 25c min. 85c min. 125c typical: statistical mean @25c maximum: mean (worst-case) + 3
pic16f913/914/916/917/946 ds41250f-page 300 ? 2007 microchip technology inc. figure 20-34: adc clock period vs. v dd over temperature figure 20-35: typical hfin tosc start-up times vs. v dd over temperature 0 2 4 6 8 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) time ( s) 25c 85c 125c -40c typical: statistical mean @25c maximum: mean (worst-case temp) + 3 (-40c to 125c) 0 2 4 6 8 10 12 14 16 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) time ( s) 85c 25c -40c typical: statistical mean @25c maximum: mean (worst-case) + 3
? 2007 microchip technology inc. ds41250f-page 301 pic16f913/914/916/917/946 figure 20-36: maximum hfintosc start-up times vs. v dd over temperature figure 20-37: minimum hfintosc start-up times vs. v dd over temperature - 40c to +85c 0 5 10 15 20 25 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) time ( s) -40c 85c 25c typical: statistical mean @25c maximum: mean (worst-case) + 3 -40c to +85c 0 1 2 3 4 5 6 7 8 9 10 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) time ( s) -40c 25c 85c typical: statistical mean @25c maximum: mean (worst-case temp) + 3
pic16f913/914/916/917/946 ds41250f-page 302 ? 2007 microchip technology inc. figure 20-38: typical hfin tosc frequency change vs. v dd (25c) figure 20-39: typical hfintosc frequency change over device v dd (85c) -5 -4 -3 -2 -1 0 1 2 3 4 5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) change from calibration (%) -5 -4 -3 -2 -1 0 1 2 3 4 5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) change from calibration (%)
? 2007 microchip technology inc. ds41250f-page 303 pic16f913/914/916/917/946 figure 20-40: typical hfin tosc frequency change vs. v dd (125c) figure 20-41: typical hfin tosc frequency change vs. v dd (-40c) -5 -4 -3 -2 -1 0 1 2 3 4 5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) change from calibration (%) -5 -4 -3 -2 -1 0 1 2 3 4 5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) change from calibration (%)
pic16f913/914/916/917/946 ds41250f-page 304 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 305 pic16f913/914/916/917/946 21.0 packaging information 21.1 package marking information 3 e 3 e * standard pic ? device marking consists of microchip part number, year code, week code and traceability code. for pic ? device marking beyond this, certain price adders apply. please check with your microchip sales office. for qtp devices, any special marking adders are included in qtp price. 40-lead pdip xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx yywwnnn example pic16F914 0710017 example 28-lead qfn xxxxxxxx xxxxxxxx yywwnnn 16f916 -i/ml 0710017 28-lead spdip xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx yywwnnn example pic16f913 0710017 legend: xx...x customer-specific information y year code (last digit of calendar year) yy year code (last 2 digits of calendar year) ww week code (week of january 1 is week ?01?) nnn alphanumeric traceability code pb-free jedec designator for matte tin (sn) * this package is pb-free. the pb-free jedec designator ( ) can be found on the outer packaging for this package. note : in the event the full microchip part number cannot be marked on one line, it will be carried over to the next line, thus limiting the number of available characters for customer-specific information. 3 e 3 e -i/sp -i/p 3 e
pic16f913/914/916/917/946 ds41250f-page 306 ? 2007 microchip technology inc. package marking information (continued) 3 e 28-lead soic xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx yywwnnn example 0710017 28-lead ssop xxxxxxxxxxxx xxxxxxxxxxxx yywwnnn example pic16f916 0710017 xxxxxxxxxx 44-lead qfn xxxxxxxxxx xxxxxxxxxx yywwnnn example pic16F914 -i/ml 0710017 44-lead tqfp xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx yywwnnn example pic16f917 0710017 64-lead tqfp (10x10x1mm) xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx yywwnnn example pic16f946 -i/pt 0710017 -i/so 3 e pic16f913 -i/ss 3 e -i/pt 3 e 3 e
? 2007 microchip technology inc. ds41250f-page 307 pic16f913/914/916/917/946 21.2 package details the following sections give the technical details of the packages. 28-lead skinny plastic dual in-line (sp) ? 300 mil body [spdip] notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. significant characteristic. 3. dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010" per side. 4. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units inches dimension limits min nom max number of pins n 28 pitch e .100 bsc top to seating plane a ? ? .200 molded package thickness a2 .120 .135 .150 base to seating plane a1 .015 ? ? shoulder to shoulder width e .290 .310 .335 molded package width e1 .240 .285 .295 overall length d 1.345 1.365 1.400 tip to seating plane l .110 .130 .150 lead thickness c .008 .010 .015 upper lead width b1 .040 .050 .070 lower lead width b .014 .018 .022 overall row spacing eb ? ? .430 note 1 n 12 d e1 e b c e l a2 e b b1 a1 a 3 microchip technology drawing c04-070 b
pic16f913/914/916/917/946 ds41250f-page 308 ? 2007 microchip technology inc. 40-lead plastic dual in-line (p) ? 600 mil body [pdip] notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. significant characteristic. 3. dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010" per side. 4. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units inches dimension limits min nom max number of pins n 40 pitch e .100 bsc top to seating plane a ? ? .250 molded package thickness a2 .125 ? .195 base to seating plane a1 .015 ? ? shoulder to shoulder width e .590 ? .625 molded package width e1 .485 ? .580 overall length d 1.980 ? 2.095 tip to seating plane l .115 ? .200 lead thickness c .008 ? .015 upper lead width b1 .030 ? .070 lower lead width b .014 ? .023 overall row spacing eb ? ? .700 n note 1 e1 d 12 3 a a1 b1 b e c e b e l a2 microchip technology drawing c04-016 b
? 2007 microchip technology inc. ds41250f-page 309 pic16f913/914/916/917/946 28-lead plastic quad flat, no lead package (ml) ? 6x6 mm body [qfn] with 0.55 mm contact length notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. package is saw singulated. 3. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 28 pitch e 0.65 bsc overall height a 0.80 0.90 1.00 standoff a1 0.00 0.02 0.05 contact thickness a3 0.20 ref overall width e 6.00 bsc exposed pad width e2 3.65 3.70 4.20 overall length d 6.00 bsc exposed pad length d2 3.65 3.70 4.20 contact width b 0.23 0.30 0.35 contact length l 0.50 0.55 0.70 contact-to-exposed pad k 0.20 ? ? d exposed d2 e b k e2 e l n note 1 1 2 2 1 n a a1 a 3 top view bottom view pad microchip technology drawing c04-105 b
pic16f913/914/916/917/946 ds41250f-page 310 ? 2007 microchip technology inc. 44-lead plastic quad flat, no lead package (ml) ? 8x8 mm body [qfn] notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. package is saw singulated. 3. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 44 pitch e 0.65 bsc overall height a 0.80 0.90 1.00 standoff a1 0.00 0.02 0.05 contact thickness a3 0.20 ref overall width e 8.00 bsc exposed pad width e2 6.30 6.45 6.80 overall length d 8.00 bsc exposed pad length d2 6.30 6.45 6.80 contact width b 0.25 0.30 0.38 contact length l 0.30 0.40 0.50 contact-to-exposed pad k 0.20 ? ? d exposed pad d2 e b k l e2 2 1 n note 1 2 1 e n bottom view top view a 3 a1 a microchip technology drawing c04-103b
? 2007 microchip technology inc. ds41250f-page 311 pic16f913/914/916/917/946 28-lead plastic small outline (so) ? wide, 7.50 mm body [soic] notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. significant characteristic. 3. dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.15 mm per side. 4. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 28 pitch e 1.27 bsc overall height a ? ? 2.65 molded package thickness a2 2.05 ? ? standoff a1 0.10 ? 0.30 overall width e 10.30 bsc molded package width e1 7.50 bsc overall length d 17.90 bsc chamfer (optional) h 0.25 ? 0.75 foot length l 0.40 ? 1.27 footprint l1 1.40 ref foot angle top 0 ? 8 lead thickness c 0.18 ? 0.33 lead width b 0.31 ? 0.51 mold draft angle top 5 ? 15 mold draft angle bottom 5 ? 15 c h h l l1 a2 a1 a note 1 12 3 b e e e1 d n microchip technology drawing c04-052b
pic16f913/914/916/917/946 ds41250f-page 312 ? 2007 microchip technology inc. 28-lead plastic shrink small outline (ss) ? 5.30 mm body [ssop] notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.20 mm per side. 3. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of pins n 28 pitch e 0.65 bsc overall height a ? ? 2.00 molded package thickness a2 1.65 1.75 1.85 standoff a1 0.05 ? ? overall width e 7.40 7.80 8.20 molded package width e1 5.00 5.30 5.60 overall length d 9.90 10.20 10.50 foot length l 0.55 0.75 0.95 footprint l1 1.25 ref lead thickness c 0.09 ? 0.25 foot angle 0 4 8 lead width b 0.22 ? 0.38 l l1 c a2 a1 a e e1 d n 1 2 note 1 b e microchip technology drawing c04-073b
? 2007 microchip technology inc. ds41250f-page 313 pic16f913/914/916/917/946 44-lead plastic thin quad flatpack (pt) ? 10x10x1 mm body, 2.00 mm footprint [tqfp] notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. chamfers at corners are optional; size may vary. 3. dimensions d1 and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.25 mm per side. 4. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of leads n 44 lead pitch e 0.80 bsc overall height a ? ? 1.20 molded package thickness a2 0.95 1.00 1.05 standoff a1 0.05 ? 0.15 foot length l 0.45 0.60 0.75 footprint l1 1.00 ref foot angle 0 3.5 7 overall width e 12.00 bsc overall length d 12.00 bsc molded package width e1 10.00 bsc molded package length d1 10.00 bsc lead thickness c 0.09 ? 0.20 lead width b 0.30 0.37 0.45 mold draft angle top 11 12 13 mold draft angle bottom 11 12 13 a e e1 d d1 e b note 1 note 2 n 12 3 c a1 l a2 l1 microchip technology drawing c04-076 b
pic16f913/914/916/917/946 ds41250f-page 314 ? 2007 microchip technology inc. 64-lead plastic thin quad flatpack (pt) ? 10x10x1 mm body, 2.00 mm footprint [tqfp] notes: 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. chamfers at corners are optional; size may vary. 3. dimensions d1 and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed 0.25 mm per side. 4. dimensioning and tolerancing per asme y14.5m. bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging units millimeters dimension limits min nom max number of leads n 64 lead pitch e 0.50 bsc overall height a ? ? 1.20 molded package thickness a2 0.95 1.00 1.05 standoff a1 0.05 ? 0.15 foot length l 0.45 0.60 0.75 footprint l1 1.00 ref foot angle 0 3.5 7 overall width e 12.00 bsc overall length d 12.00 bsc molded package width e1 10.00 bsc molded package length d1 10.00 bsc lead thickness c 0.09 ? 0.20 lead width b 0.17 0.22 0.27 mold draft angle top 11 12 13 mold draft angle bottom 11 12 13 d d1 e e1 e b n note 1 12 3 note 2 c l a1 l1 a2 a microchip technology drawing c04-085b
? 2007 microchip technology inc. ds41250f-page 315 pic16f913/914/916/917/946 appendix a: data sheet revision history revision a this is a new data sheet. revision b updated peripheral features. page 2, table: corrected i/o numbers. figure 8-3: revised comparator i/o operating modes. register 9-1, table: corrected max. number of pixels. revision c correction to pin description table. correction to ipd base and t1osc. revision d revised references 31.25 khz to 31 khz. revised standby current to 100 na. revised 9.1: internal rc oscillator to internal lf oscillator. revision e removed ?advance information? from section 19.0 electrical specifications. removed 28-lead plastic quad flat no lead package (ml) (qfn-s) package. revision f updates throughout document. removed ?preliminary? from data sheet. added characterization data chapter. update electrical specifications chapter. added pic16f946 device. appendix b: migrating from other pic ? devices this discusses some of the issues in migrating from other pic ? devices to the pic16f91x/946 family of devices. b.1 pic16f676 to pic16f91x/946 table b-1: feature comparison feature pic16f676 pic16f91x/ 946 max. operating speed 20 mhz 20 mhz max. program memory (words) 1k 8k max. sram (bytes) 64 352 a/d resolution 10-bit 10-bit data eeprom (bytes) 128 256 timers (8/16-bit) 1/1 2/1 oscillator modes 8 8 brown-out reset y y internal pull-ups rb0/1/2/4/5 rb<7:0> interrupt-on-change rb0/1/2/3 /4/5 rb<7:4> comparator 1 2 usart n y extended wdt n y software control option of wdt/bor ny intosc frequencies 4 mhz 32 khz - 8mhz clock switching n y
pic16f913/914/916/917/946 ds41250f-page 316 ? 2007 microchip technology inc. appendix c: conversion considerations considerations for converting from previous versions of devices to the ones listed in this data sheet are listed in table c-1. table c-1: conversi on considerations characteristic pic16f91x/946 pic16f87x pic16f87xa pins 28/40/64 28/40 28/40 timers 3 3 3 interrupts 11 or 12 13 or 14 14 or 15 communication usart, ssp (1) (spi, i 2 c? slave) psp, usart, ssp (spi, i 2 c master/slave) psp, usart, ssp (spi, i 2 c master/slave) frequency 20 mhz 20 mhz 20 mhz voltage 2.0v-5.5v 2.2v-5.5v 2.0v-5.5v a/d 10-bit, 7 conversion clock selects 10-bit, 4 conversion clock selects 10-bit, 7 conversion clock selects ccp 2 2 2 comparator 2 ? 2 comparator voltage reference yes ? yes program memory 4k, 8k flash 4k, 8k flash (erase/write on single-word) 4k, 8k flash (erase/write on four-word blocks) ram 256, 336, 352 bytes 192, 368 bytes 192, 368 bytes eeprom data 256 bytes 128, 256 bytes 128, 256 bytes code protection on/off segmented, starting at end of program memory on/off program memory write protection ? on/off segmented, starting at beginning of program memory lcd module 16, 24 segment drivers, 4 commons ?? other in-circuit debugger, low-voltage programming in-circuit debugger, low-voltage programming in-circuit debugger, low-voltage programming note 1: ssp aand usart share the same pins on the pic16f91x.
? 2007 microchip technology inc. ds41250f-page 317 pic16f917/916/914/913 index a a/d specifications.................................................... 272, 273 absolute maximum ratings .............................................. 255 ac characteristics industrial and extended ............................................ 265 load conditions ........................................................ 264 ack pulse ......................................................................... 202 adc .................................................................................. 175 acquisition requirements ......................................... 183 associated registers.................................................. 185 block diagram........................................................... 175 calculating acquisition time..................................... 183 channel selection..................................................... 176 configuration............................................................. 176 configuring interrupt ................................................. 179 conversion clock...................................................... 176 conversion procedure .............................................. 179 internal sampling switch (r ss ) impedance.............. 183 interrupts................................................................... 177 operation .................................................................. 178 operation during sleep ............................................ 178 port configuration ..................................................... 176 reference voltage (v ref )......................................... 176 result formatting...................................................... 178 source impedance.................................................... 183 special event trigger................................................ 178 starting an a/d conversion ...................................... 178 adcon0 register............................................................. 180 adcon1 register............................................................. 181 addressable universal synchronous asynchronous receiver transmitter (ausart)....... 121 adresh register (adfm = 0) ......................................... 182 adresh register (adfm = 1) ......................................... 182 adresl register (adfm = 0).......................................... 182 adresl register (adfm = 1).......................................... 182 analog input connection considerations.......................... 111 analog-to-digital converter. see adc ansel register.................................................................. 43 assembler mpasm assembler................................................... 252 ausart ........................................................................... 121 associated registers baud rate generator........................................ 132 asynchronous mode ................................................. 123 associated registers receive..................................................... 129 transmit.................................................... 125 baud rate generator (brg) ............................ 132 receiver............................................................ 126 setting up 9-bit mode with address detect....... 128 transmitter........................................................ 123 baud rate generator (brg) baud rate error, calculating ............................ 132 baud rates, asynchronous modes .................. 133 formulas ........................................................... 132 high baud rate select (brgh bit) .................. 132 synchronous master mode ............................... 135, 139 associated registers receive..................................................... 138 transmit.................................................... 136 reception.......................................................... 137 transmission .................................................... 135 synchronous slave mode associated registers receive .................................................... 140 transmit ................................................... 139 reception ......................................................... 140 transmission .................................................... 139 b bf bit ................................................................................ 194 block diagram of rf........................................................... 83 block diagrams (ccp) capture mode operation ............................... 213 adc .......................................................................... 175 adc transfer function ............................................. 184 analog input model........................................... 111, 184 ausart receive ..................................................... 122 ausart transmit .................................................... 121 ccp pwm ................................................................ 215 clock source .............................................................. 87 comparator 1............................................................ 110 comparator 2............................................................ 110 comparator modes................................................... 113 compare................................................................... 214 crystal operation........................................................ 90 external rc mode ...................................................... 91 fail-safe clock monitor (fscm)................................. 97 in-circuit serial programming connections ............. 238 interrupt logic........................................................... 231 lcd clock generation.............................................. 150 lcd driver module ................................................... 144 lcd resistor ladder connection............................. 148 mclr circuit ............................................................ 222 on-chip reset circuit............................................... 221 pic16f913/916 .......................................................... 15 pic16F914/917 .......................................................... 16 pic16f946 ................................................................. 17 ra0 pin ...................................................................... 45 ra1 pin ...................................................................... 46 ra2 pin ...................................................................... 47 ra3 pin ...................................................................... 48 ra4 pin ...................................................................... 49 ra5 pin ...................................................................... 50 ra6 pin ...................................................................... 51 ra7 pin ...................................................................... 52 rb pins....................................................................... 56 rb4 pin ...................................................................... 57 rb5 pin ...................................................................... 58 rb6 pin ...................................................................... 59 rb7 pin ...................................................................... 60 rc0 pin ...................................................................... 63 rc1 pin ...................................................................... 64 rc2 pin ...................................................................... 64 rc3 pin ...................................................................... 65 rc4 pin ...................................................................... 66 rc5 pin ...................................................................... 67 rc6 pin ...................................................................... 68 rc7 pin ...................................................................... 69 rd pins ...................................................................... 74 rd0 pin ...................................................................... 73 rd1 pin ...................................................................... 73 rd2 pin ...................................................................... 74 re pins....................................................................... 78 re pins....................................................................... 79 resonator operation .................................................. 90 rf pins....................................................................... 83
pic16f917/916/914/913 ds41250f-page 318 ? 2007 microchip technology inc. rg pins....................................................................... 85 ssp (i 2 c mode) ........................................................ 202 ssp (spi mode)........................................................ 193 timer1 ....................................................................... 102 timer2 ....................................................................... 107 tmr0/wdt prescaler ................................................. 99 watchdog timer (wdt) ............................................ 234 brown-out reset (bor) .................................................... 223 associated registers ................................................ 224 calibration ................................................................. 223 specifications............................................................ 269 timing and characteristics ....................................... 268 c c compilers mplab c18 .............................................................. 252 mplab c30 .............................................................. 252 capture module. see capture/compare/pwm (ccp) capture/compare/pwm (ccp)......................................... 211 associated registers w/ capture/compare/pwm...... 218 capture mode ........................................................... 213 ccpx pin configuration ............................................ 213 compare mode ......................................................... 214 ccpx pin configuration .................................... 214 software interrupt mode ........................... 213, 214 special event trigger........................................ 214 timer1 mode selection ............................. 213, 214 interaction of two ccp modules (table) ................... 211 prescaler................................................................... 213 pwm mode ............................................................... 215 duty cycle......................................................... 216 effects of reset................................................. 218 example pwm frequencies and resolutions, 20 mhz ................................ 217 example pwm frequencies and resolutions, 8 mhz................................... 217 operation in sleep mode .................................. 218 setup for operation........................................... 218 system clock frequency changes................... 218 pwm period .............................................................. 216 setup for pwm operation ......................................... 218 timer resources....................................................... 211 ccp. see capture/compare/pwm (ccp) ccpxcon register .......................................................... 212 cke bit .............................................................................. 194 ckp bit .............................................................................. 195 clock sources external modes ........................................................... 89 ec ....................................................................... 89 hs ....................................................................... 90 lp........................................................................ 90 ost..................................................................... 89 rc....................................................................... 91 xt ....................................................................... 90 internal modes ............................................................ 91 frequency selection ........................................... 93 hfintosc.......................................................... 91 intosc .............................................................. 91 intoscio........................................................... 91 lfintosc .......................................................... 93 clock switching................................................................... 95 cmcon0 register ............................................................ 116 cmcon1 register ............................................................ 117 code examples a/d conversion ......................................................... 179 assigning prescaler to timer0 .................................. 100 assigning prescaler to wdt..................................... 100 call of a subroutine in page 1 from page 0 ............... 40 changing between capture prescalers.................... 213 indirect addressing ..................................................... 41 initializing porta....................................................... 44 initializing portb....................................................... 53 initializing portc ...................................................... 62 initializing portd ...................................................... 71 initializing porte....................................................... 76 initializing portf....................................................... 81 initializing portg ...................................................... 84 loading the sspbuf (sspsr) register.................. 196 saving status and w registers in ram ................... 233 code protection ................................................................ 238 comparator....................................................................... 109 c2out as t1 gate................................................... 117 configurations .......................................................... 112 interrupts .................................................................. 114 operation .......................................................... 109, 114 operation during sleep ............................................ 115 response time......................................................... 114 synchronizing cout w/timer1 ................................ 117 comparator module associated registers ................................................. 119 comparator voltage reference (cv ref ) response time......................................................... 114 comparator voltage reference (cv ref ).......................... 118 effects of a reset ..................................................... 115 specifications ........................................................... 271 comparators c2out as t1 gate................................................... 103 effects of a reset ..................................................... 115 specifications ........................................................... 271 compare module. see capture/compare/pwm (ccp) config1 register ........................................................... 220 configuration bits ............................................................. 220 conversion considerations............................................... 316 cpu features ................................................................... 219 customer change notification service............................. 325 customer notification service .......................................... 325 customer support............................................................. 325 d d/a bit ............................................................................... 194 data eeprom memory.................................................... 187 associated registers ................................................ 192 reading .................................................................... 190 writing ...................................................................... 190 data memory ...................................................................... 24 data/address bit (d/a )...................................................... 194 dc and ac characteristics graphs and tables ................................................... 283 dc characteristics extended and industrial ............................................ 261 industrial and extended ............................................ 257 development support ....................................................... 251 device overview................................................................. 15 e eeadrh registers................................................... 187, 188 eeadrl register ............................................................. 188 eeadrl registers ........................................................... 187 eecon1 register..................................................... 187, 189 eecon2 register............................................................. 187 eedath register............................................................. 188 eedatl register ............................................................. 188
? 2007 microchip technology inc. ds41250f-page 319 pic16f917/916/914/913 effects of reset pwm mode ............................................................... 218 electrical specifications .................................................... 255 errata .................................................................................. 13 f fail-safe clock monitor....................................................... 97 fail-safe condition clearing ....................................... 97 fail-safe detection ..................................................... 97 fail-safe operation..................................................... 97 reset or wake-up from sleep..................................... 97 firmware instructions........................................................ 241 flash program memory .................................................... 187 fuses. see configuration bits g general purpose register file............................................ 24 i i/o ports .............................................................................. 43 i 2 c mode addressing ................................................................ 203 associated registers ................................................ 209 master mode ............................................................. 208 mode selection ......................................................... 202 multi-master mode .................................................... 208 operation .................................................................. 202 reception.................................................................. 204 slave mode scl and sda pins ............................................ 202 transmission............................................................. 206 id locations ...................................................................... 238 in-circuit debugger ........................................................... 239 in-circuit serial programming (icsp) ............................... 238 indirect addressing, indf and fsr registers ................... 41 instruction format ............................................................. 241 instruction set ................................................................... 241 addlw ..................................................................... 243 addwf..................................................................... 243 andlw ..................................................................... 243 andwf..................................................................... 243 bcf........................................................................... 243 bsf ........................................................................... 243 btfsc ...................................................................... 243 btfss ...................................................................... 244 call ......................................................................... 244 clrf......................................................................... 244 clrw ....................................................................... 244 clrwdt................................................................... 244 comf ....................................................................... 244 decf ........................................................................ 244 decfsz.................................................................... 245 goto ....................................................................... 245 incf.......................................................................... 245 incfsz ..................................................................... 245 iorlw ...................................................................... 245 iorwf ...................................................................... 245 movf........................................................................ 246 movlw .................................................................... 246 movwf .................................................................... 246 nop .......................................................................... 246 retfie ..................................................................... 247 retlw ..................................................................... 247 return ................................................................... 247 rlf ........................................................................... 248 rrf........................................................................... 248 sleep ...................................................................... 248 sublw..................................................................... 248 subwf..................................................................... 249 swapf..................................................................... 249 xorlw .................................................................... 249 xorwf .................................................................... 249 summary table ........................................................ 242 intcon register................................................................ 34 inter-integrated circuit (i 2 c). see i 2 c mode internal oscillator block intosc specifications ........................................... 266, 267 internal sampling switch (r ss ) impedance ..................... 183 internet address ............................................................... 325 interrupts .......................................................................... 230 adc .......................................................................... 179 associated registers................................................ 232 comparator............................................................... 114 context saving ......................................................... 233 interrupt-on-change .................................................... 53 portb interrupt-on-change.................................... 231 rb0/int/seg0 ......................................................... 231 tmr0........................................................................ 231 tmr1........................................................................ 104 intosc specifications ............................................. 266, 267 iocb register..................................................................... 54 l lcd associated registers................................................ 168 bias types................................................................ 148 clock source selection ............................................ 148 configuring the module ............................................ 167 disabling the module ................................................ 167 frame frequency ..................................................... 149 interrupts .................................................................. 164 lcdcon register .................................................... 143 lcddata register .................................................. 143 lcdps register ....................................................... 143 multiplex types......................................................... 149 operation during sleep ............................................ 165 pixel control ............................................................. 149 prescaler .................................................................. 148 segment enables ..................................................... 149 waveform generation .............................................. 153 lcdcon register .................................................... 143, 145 lcddata register........................................................... 143 lcddatax registers ..................... .................................. 147 lcdps register ....................................................... 143, 146 lp bits ...................................................................... 148 lcdsen registers............................................................ 147 liquid crystal display (lcd) driver .................................. 143 load conditions................................................................ 264 m mclr ............................................................................... 222 internal...................................................................... 222 memory organization ......................................................... 23 data ............................................................................ 24 program...................................................................... 23 microchip internet web site.............................................. 325 migrating from other pic microcontroller devices ............ 315 mplab asm30 assembler, linker, librarian ................... 252 mplab icd 2 in-circuit debugger ................................... 253 mplab ice 2000 high-performance universal in-circuit emulator.................................................... 253
pic16f917/916/914/913 ds41250f-page 320 ? 2007 microchip technology inc. mplab integrated development environment software .. 251 mplab pm3 device programmer..................................... 253 mplab real ice in-circuit emulator system................. 253 mplink object linker/mplib object librarian ................ 252 o opcode field descriptions ............................................. 241 option register ................................................................ 33 option_reg register .................................................... 101 osccon register .............................................................. 88 oscillator associated registers............................................ 98, 106 oscillator module ................................................................ 87 ec ............................................................................... 87 hfintosc.................................................................. 87 hs ............................................................................... 87 intosc ...................................................................... 87 intoscio................................................................... 87 lfintosc .................................................................. 87 lp................................................................................ 87 rc ............................................................................... 87 rcio ........................................................................... 87 xt ............................................................................... 87 oscillator parameters........................................................ 266 oscillator specifications .................................................... 265 oscillator start-up timer (ost) specifications............................................................ 269 oscillator switching fail-safe clock monitor............................................... 97 two-speed clock start-up .......................................... 95 osctune register ............................................................ 92 p p (stop) bit ........................................................................ 194 packaging ......................................................................... 305 marking ............................................................. 305, 306 pdip details.............................................................. 307 paging, program memory ................................................... 40 pcl and pclath ............................................................... 40 computed goto ........................................................ 40 stack ........................................................................... 40 pcon register ........................................................... 39, 224 picstart plus development programmer ..................... 254 pie1 register ...................................................................... 35 pie2 register ...................................................................... 36 pin diagram pic16f913/916, 28-pin ................................................. 4 pic16F914/917, 40-pin ................................................. 2 pic16F914/917, 44-pin ................................................. 7 pic16f946, 64-pin ..................................................... 10 pinout description ............................................................... 18 pir1 register...................................................................... 37 pir2 register...................................................................... 38 plvd associated registers ................................................ 173 porta additional pin functions ansel register.................................................. 43 associated registers .................................................. 52 pin descriptions and diagrams................................... 45 ra0 ............................................................................. 45 ra1 ............................................................................. 46 ra2 ............................................................................. 47 ra3 ............................................................................. 48 ra4 ............................................................................. 49 ra5 ............................................................................. 50 ra6............................................................................. 51 ra7............................................................................. 52 registers .................................................................... 44 specifications ........................................................... 267 porta register ................................................................. 44 portb additional pin functions ............................................. 53 weak pull-up ...................................................... 53 associated registers .................................................. 61 interrupt-on-change .................................................... 53 pin descriptions and diagrams .................................. 56 rb0............................................................................. 56 rb1............................................................................. 56 rb2............................................................................. 56 rb3............................................................................. 56 rb4............................................................................. 57 rb5............................................................................. 58 rb6............................................................................. 59 rb7............................................................................. 60 registers .................................................................... 53 portb register ................................................................. 54 portc associated registers .................................................. 70 pin descriptions and diagrams .................................. 63 rc0 ............................................................................ 63 rc1 ............................................................................ 63 rc2 ............................................................................ 63 rc3 ............................................................................ 65 rc4 ............................................................................ 66 rc5 ............................................................................ 67 rc6 ............................................................................ 68 rc7 ............................................................................ 69 registers .................................................................... 62 specifications ........................................................... 267 portc register................................................................. 62 portd associated registers .................................................. 75 pin descriptions and diagrams .................................. 72 rd0 ............................................................................ 72 rd1 ............................................................................ 72 rd2 ............................................................................ 72 rd3 ............................................................................ 72 rd4 ............................................................................ 72 rd5 ............................................................................ 72 rd6 ............................................................................ 72 rd7 ............................................................................ 72 registers .................................................................... 71 portd register................................................................. 71 porte associated registers .................................................. 80 pin descriptions and diagrams .................................. 77 re0............................................................................. 77 re1............................................................................. 77 re2............................................................................. 77 re3............................................................................. 77 re4............................................................................. 77 re5............................................................................. 77 re6............................................................................. 77 re7............................................................................. 77 registers .................................................................... 76 porte register ................................................................. 76 portf associated registers .................................................. 83 pin descriptions and diagrams .................................. 82 registers .................................................................... 81
? 2007 microchip technology inc. ds41250f-page 321 pic16f917/916/914/913 rf0 ............................................................................. 82 rf1 ............................................................................. 82 rf2 ............................................................................. 82 rf3 ............................................................................. 82 rf4 ............................................................................. 82 rf5 ............................................................................. 82 rf6 ............................................................................. 82 rf7 ............................................................................. 82 portf register ................................................................. 81 portg associated registers .................................................. 86 pin descriptions and diagrams................................... 85 registers..................................................................... 84 rg0............................................................................. 85 rg1............................................................................. 85 rg2............................................................................. 85 rg3............................................................................. 85 rg4............................................................................. 85 rg5............................................................................. 85 portg register................................................................. 84 power-down mode (sleep) ............................................... 236 power-on reset ................................................................ 222 power-up timer (pwrt) .................................................. 222 specifications............................................................ 269 precision internal oscillator parameters........................... 267 prescaler shared wdt/timer0 ................................................. 100 switching prescaler assignment............................... 100 product identification system ........................................... 327 program memory ................................................................ 23 map and stack (pic16f913/914) ............................... 23 map and stack (pic16f916/917/946) ........................ 23 paging......................................................................... 40 programmable low-voltage detect (plvd) module ........ 171 plvd operation........................................................ 171 programming, device instructions .................................... 241 r r/w bit .............................................................................. 194 rcreg ............................................................................. 128 rcsta register ............................................................... 131 reader response ............................................................. 326 read-modify-write operations ......................................... 241 receive overflow indicator bit (sspov) .......................... 195 registers adcon0 (adc control 0) ........................................ 180 adcon1 (adc control 1) ........................................ 181 adresh (adc result high) with adfm = 0)........... 182 adresh (adc result high) with adfm = 1)........... 182 adresl (adc result low) with adfm = 0) ............ 182 adresl (adc result low) with adfm = 1) ............ 182 ansel (analog select)............................................... 43 ccpxcon (ccp operation)..................................... 212 cmcon0 (comparator control 0) ............................ 116 cmcon1 (comparator control 1) ............................ 117 config1 (configuration word register 1) .............. 220 eeadrh (eeprom address high byte) ................. 188 eeadrl (eeprom address low byte)................... 188 eecon1 (eeprom control 1)................................. 189 eedath (eeprom data high byte) ....................... 188 eedatl (eeprom data low byte)......................... 188 intcon (interrupt control)......................................... 34 iocb (portb interrupt-on-change)........................... 54 lcdcon (lcd control)............................................ 145 lcddatax (lcd data) ............................................ 147 lcdps (lcd prescaler select) ................................ 146 lcdsen (lcd segment enable) ............................. 147 lvdcon (low-voltage detect control) ................... 173 option_reg (option)................................... 33, 101 osccon (oscillator control)..................................... 88 osctune (oscillator tuning).................................... 92 pcon (power control register)................................. 39 pcon (power control) ............................................. 224 pie1 (peripheral interrupt enable 1) .......................... 35 pie2 (peripheral interrupt enable 2) .......................... 36 pir1 (peripheral interrupt register 1) ........................ 37 pir2 (peripheral interrupt request 2) ........................ 38 porta ....................................................................... 44 portb ....................................................................... 54 portc ....................................................................... 62 portd ....................................................................... 71 porte ....................................................................... 76 portf ....................................................................... 81 portg....................................................................... 84 rcsta (receive status and control) ...................... 131 reset values ............................................................ 226 reset values (special registers)............................. 229 special function register map pic16f913/916 .................................................. 25 pic16F914/917 .................................................. 26 pic16f946 ......................................................... 27 special register summary bank 0 ................................................................ 28 bank 1 ................................................................ 29 bank 2 ................................................................ 30 bank 3 ................................................................ 31 sspcon (sync serial port control) register .......... 195 sspstat (sync serial port status) register .......... 194 status ..................................................................... 32 t1con ..................................................................... 105 t2con ..................................................................... 108 trisa (tri-state porta) .......................................... 44 trisb (tri-state portb) .......................................... 54 trisc (tri-state portc) .......................................... 62 trisd (tri-state portd) .......................................... 71 trise (tri-state porte) .......................................... 76 trisf (tri-state portf)........................................... 81 trisg (tri-state portg).......................................... 84 txsta (transmit status and control)...................... 130 vrcon (voltage reference control) ....................... 118 wdtcon (watchdog timer control) ....................... 235 wpub (weak pull-up portb)................................... 55 reset ................................................................................ 221 revision history................................................................ 315 s s (start) bit ....................................................................... 194 slave select synchronization ........................................... 199 smp bit ............................................................................. 194 software simulator (mplab sim) .................................... 252 spbrg ............................................................................. 132 special event trigger ....................................................... 178 special function registers ................................................. 24 spi mode .................................................................. 193, 199 associated registers................................................ 201 bus mode compatibility ............................................ 201 effects of a reset ..................................................... 201 enabling spi i/o ....................................................... 197 master mode............................................................. 198 master/slave connection ......................................... 197 serial clock (sck pin).............................................. 193 serial data in (sdi pin)............................................. 193
pic16f917/916/914/913 ds41250f-page 322 ? 2007 microchip technology inc. serial data out (sdo pin) ........................................ 193 slave select .............................................................. 193 slave select synchronization ................................... 199 sleep operation ........................................................ 201 spi clock .................................................................. 198 typical connection ................................................... 197 ssp overview spi master/slave connection ................................... 197 ssp i 2 c operation ............................................................ 202 slave mode ............................................................... 202 ssp module clock synchronization and the ckp bit .................... 208 spi master mode ...................................................... 198 spi slave mode ........................................................ 199 sspbuf.................................................................... 198 sspsr ...................................................................... 198 sspcon register............................................................. 195 sspen bit ......................................................................... 195 sspm bits ......................................................................... 195 sspov bit ......................................................................... 195 sspstat register ........................................................... 194 status register................................................................ 32 synchronous serial port enable bit (sspen)................... 195 synchronous serial port mode select bits (sspm) .......... 195 synchronous serial port. see ssp t t1con register................................................................ 105 t2con register................................................................ 108 thermal considerations .................................................... 263 time-out sequence........................................................... 224 timer0 ................................................................................. 99 associated registers ................................................ 101 external clock........................................................... 100 interrupt..................................................................... 101 operation ............................................................ 99, 102 specifications............................................................ 270 t0cki ........................................................................ 100 timer1 ............................................................................... 102 associated registers.................................................. 106 asynchronous counter mode ................................... 103 reading and writing ......................................... 103 interrupt..................................................................... 104 modes of operation .................................................. 102 operation during sleep ............................................ 104 oscillator ................................................................... 103 prescaler................................................................... 103 specifications............................................................ 270 timer1 gate inverting gate ................................................... 103 selecting source....................................... 103, 117 synchronizing cout w/timer1 ........................ 117 tmr1h register ....................................................... 102 tmr1l register........................................................ 102 timer2 associated registers.................................................. 108 timers timer1 t1con.............................................................. 105 timer2 t2con.............................................................. 108 timing diagrams a/d conversion ......................................................... 274 a/d conversion (sleep mode) .................................. 274 asynchronous reception .......................................... 128 asynchronous transmission..................................... 124 asynchronous transmission (back-to-back)............ 124 brown-out reset (bor)............................................ 268 brown-out reset situations ...................................... 223 capture/compare/pwm ........................................... 276 clkout and i/o ...................................................... 267 clock synchronization .............................................. 209 clock timing ............................................................. 265 comparator output ................................................... 109 fail-safe clock monitor (fscm)................................. 98 i 2 c bus data............................................................. 281 i 2 c bus start/stop bits ............................................. 280 i 2 c reception (7-bit address)................................... 204 i 2 c slave mode (transmission, 10-bit address)....... 207 i 2 c slave mode with sen = 0 (reception, 10-bit address) ................................................. 205 i 2 c transmission (7-bit address).............................. 206 int pin interrupt ....................................................... 232 internal oscillator switch timing ................................ 94 lcd interrupt timing in quarter-duty cycle drive ... 164 lcd sleep entry/exit when slpen = 1 or cs = 00 . 166 reset, wdt, ost and power-up timer ................... 268 slave synchronization .............................................. 199 spi master mode (cke = 1, smp = 1) ..................... 278 spi mode (master mode).......................................... 198 spi mode (slave mode with cke = 0)...................... 200 spi mode (slave mode with cke = 1)...................... 200 spi slave mode (cke = 0) ....................................... 279 spi slave mode (cke = 1) ....................................... 279 synchronous reception (master mode, sren) ....... 138 synchronous transmission ...................................... 136 synchronous transmission (through txen) ........... 136 time-out sequence case 1 .............................................................. 225 case 2 .............................................................. 225 case 3 .............................................................. 225 timer0 and timer1 external clock ........................... 270 timer1 incrementing edge ....................................... 104 two speed start-up.................................................... 96 type-a in 1/2 mux, 1/2 bias drive ............................ 154 type-a in 1/2 mux, 1/3 bias drive ............................ 156 type-a in 1/3 mux, 1/2 bias drive ............................ 158 type-a in 1/3 mux, 1/3 bias drive ............................ 160 type-a in 1/4 mux, 1/3 bias drive ............................ 162 type-a/type-b in static drive .................................. 153 type-b in 1/2 mux, 1/2 bias drive ............................ 155 type-b in 1/2 mux, 1/3 bias drive ............................ 157 type-b in 1/3 mux, 1/2 bias drive ............................ 159 type-b in 1/3 mux, 1/3 bias drive ............................ 161 type-b in 1/4 mux, 1/3 bias drive ............................ 163 usart synchronous receive (master/slave) ......... 275 usart synchronous transmission (master/slave). 275 wake-up from interrupt............................................. 237 timing parameter symbology .......................................... 264 timing requirements i 2 c bus data............................................................. 282 i2c bus start/stop bits............................................. 281 spi mode .................................................................. 280 trisa registers .................................................................... 44 trisa register................................................................... 44 trisb registers .................................................................... 53 trisb register................................................................... 54 trisc
? 2007 microchip technology inc. ds41250f-page 323 pic16f917/916/914/913 registers..................................................................... 62 trisc register................................................................... 62 trisd registers..................................................................... 71 trisd register................................................................... 71 trise registers..................................................................... 76 trise register ................................................................... 76 trisf registers..................................................................... 81 trisf register ................................................................... 81 trisg registers..................................................................... 84 trisg register................................................................... 84 two-speed clock start-up mode ........................................ 95 txreg.............................................................................. 123 txsta register ................................................................ 130 brgh bit .................................................................. 132 u ua ..................................................................................... 194 update address bit, ua .................................................... 194 usart synchronous master mode requirements, synchronous receive .............. 275 requirements, synchronous transmission ...... 275 timing diagram, synchronous receive ........... 275 timing diagram, synchronous transmission ... 275 v voltage reference. see comparator voltage reference (cv ref ) voltage references associated registers.................................................. 119 v ref . s ee adc reference voltage w wake-up using interrupts ................................................. 236 watchdog timer (wdt) .................................................... 234 associated registers ................................................ 235 clock source............................................................. 234 modes ....................................................................... 234 period........................................................................ 234 specifications............................................................ 269 wcol bit .......................................................................... 195 wdtcon register ........................................................... 235 wpub register................................................................... 55 write collision detect bit (wcol)..................................... 195 www address.................................................................. 325 www, on-line support ..................................................... 13
pic16f917/916/914/913 ds41250f-page 324 ? 2007 microchip technology inc. notes:
? 2007 microchip technology inc. ds41250f-page 325 pic16f913/914/916/917/946 the microchip web site microchip provides online support via our www site at www.microchip.com. this web site is used as a means to make files and information easily available to customers. accessible by using your favorite internet browser, the web site contains the following information: ? product support ? data sheets and errata, application notes and sample programs, design resources, user?s guides and hardware support documents, latest software releases and archived software ? general technical support ? frequently asked questions (faq), technical support requests, online discussion groups, microchip consultant program member listing ? business of microchip ? product selector and ordering guides, latest microchip press releases, listing of seminars and events, listings of microchip sales offices, distributors and factory representatives customer change notification service microchip?s customer notification service helps keep customers current on microchip products. subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest. to register, access the microchip web site at www.microchip.com, click on customer change notification and follow the registration instructions. customer support users of microchip products can receive assistance through several channels: ? distributor or representative ? local sales office ? field application engineer (fae) ? technical support ? development systems information line customers should contact their distributor, representative or field application engineer (fae) for support. local sales offices are also available to help customers. a listing of sales offices and locations is included in the back of this document. technical support is available through the web site at: http://support.microchip.com
pic16f913/914/916/917/946 ds41250f-page 326 ? 2007 microchip technology inc. reader response it is our intention to provide you with the best documentation possible to ensure successful use of your microchip prod- uct. if you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation can better serve you, please fax your comments to the technical publications manager at (480) 792-4150. please list the following information, and use this outline to provide us with your comments about this document. to : technical publications manager re: reader response total pages sent ________ from: name company address city / state / zip / country telephone: (_______) _________ - _________ application (optional): would you like a reply? y n device: literature number: questions: fax: (______) _________ - _________ ds41250f pic16f913/914/916/917/946 1. what are the best features of this document? 2. how does this document meet your hardware and software development needs? 3. do you find the organization of this document easy to follow? if not, why? 4. what additions to the document do you think would enhance the structure and subject? 5. what deletions from the document could be made without affecting the overall usefulness? 6. is there any incorrect or misleading information (what and where)? 7. how would you improve this document?
? 2007 microchip technology inc. ds41250f-page 327 pic16f917/916/914/913 product identification system to order or obtain information, e. g., on pricing or delivery, refer to the factory or the listed sales office . * jw devices are uv erasable and can be programmed to any device c onfiguration. jw devices meet the electrical requirement of each oscillator type. part no. x /xx xxx pattern package temperature range device device: pic16f913, pic16f913t (1) pic16F914, pic16F914t (1) pic16f916, pic16f916t (1) pic16f917, pic16f917t (1) pic16f946, pic16f946t (1) temperature range: i= -40 c to +85 c e= -40 c to +125 c package: ml = micro lead frame (qfn) p = plastic dip pt = tqfp (thin quad flatpack) so = soic sp = skinny plastic dip ss = ssop pattern: 3-digit pattern code for qtp (blank otherwise) examples: a) pic16f913-e/sp 301 = extended temp., skinny pdip package, 20 mhz, qtp pattern #301 b) pic16f913-i/so = industrial temp., soic package, 20 mhz note 1: t = in tape and reel.
ds41250f-page 328 ? 2007 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://support.microchip.com web address: www.microchip.com atlanta duluth, ga tel: 678-957-9614 fax: 678-957-1455 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 kokomo kokomo, in tel: 765-864-8360 fax: 765-864-8387 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 santa clara santa clara, ca tel: 408-961-6444 fax: 408-961-6445 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific asia pacific office suites 3707-14, 37th floor tower 6, the gateway harbour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8528-2100 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8665-5511 fax: 86-28-8665-7889 china - fuzhou tel: 86-591-8750-3506 fax: 86-591-8750-3521 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8203-2660 fax: 86-755-8203-1760 china - shunde tel: 86-757-2839-5507 fax: 86-757-2839-5571 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xian tel: 86-29-8833-7250 fax: 86-29-8833-7256 asia/pacific india - bangalore tel: 91-80-4182-8400 fax: 91-80-4182-8422 india - new delhi tel: 91-11-4160-8631 fax: 91-11-4160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - gumi tel: 82-54-473-4301 fax: 82-54-473-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - penang tel: 60-4-646-8870 fax: 60-4-646-5086 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-572-9526 fax: 886-3-572-6459 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2500-6610 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-39 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 w orldwide s ales and s ervice 12/08/06


▲Up To Search▲   

 
Price & Availability of 16F914

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X